Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ergyl/hibernate_1tomany
School task mapping 1:M relationship using Hibernate
https://github.com/ergyl/hibernate_1tomany
hibernate
Last synced: about 2 months ago
JSON representation
School task mapping 1:M relationship using Hibernate
- Host: GitHub
- URL: https://github.com/ergyl/hibernate_1tomany
- Owner: ergyl
- Created: 2024-04-29T18:42:29.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-29T19:00:04.000Z (9 months ago)
- Last Synced: 2024-04-30T20:00:08.781Z (9 months ago)
- Topics: hibernate
- Language: Java
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A simple school task that let's me practise mapping Java (domain) objects to database tables using the javax.persistence package while learning Hibernate.
# Domain classes
- se.yrgo.domain.Animal
- se.yrgo.domain.Zoo*One Zoo can have many animals, but one animal can only be in one zoo.*
# How to run it
This task is made using Apache Derby as the database.Download Apache Derby: https://db.apache.org/derby/derby_downloads.html
## Connect to Derby
First we need to connect to our database. There are two files in the bin folder of derby which are called NetworkServerControl.bat which will be used for windows system and `NetworkServerControl.sh` which will be used for linux and mac system:
`C:\>cd db-derby-10.12.1.1-bin/bin`Windows:
`NetworkServerControl.bat -p 50000 start`Linux:
`./NetworkServerControl -p 50000 start`## Create a database in Derby
Then we need to create a database. To do that, open another terminal and open interactive shell ij:
`C:\>cd db-derby-10.12.1.1-bin/bin`Run ij:
In Windows(cmd): Run `ij.bat`
In Linux and Mac: Run `./ij`Create the database:
`connect 'jdbc:derby://localhost:50000/zoo_db; create=true' ;`Run the code from main class: src/main/se/yrgo/test/App