Skip to content

Demonistrates how to use "Foreign" generator strategy in Hibernate Framework. And also how to define One-to-One relation ship.

Notifications You must be signed in to change notification settings

lovababu/HibernateForeignKeyGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hibernate "Foreign" key generator with One-to-One mapping.

Demonstrates how to use Hibernate generator "Foreign" key strategy and one-to-one mapping. Explains the how to user H2 In memory embedded db with Hibernate and spring. Gives you the idea on custome generator creation.

TechStack.

  1. Spring Core/ORM.
  2. Hibernate Framework.
  3. Lombok api.
  4. Gradle build and dependency management.

Problem Statement.

  1. Establish the One-to-One mapping between two tables.
  2. Child table must use the Parent table id as Foreign key and as well Primary key. (This way we can avoid extra primary key column creation, reduce the overhead to db)
  3. As soon as Parent record inserted the child record should get inserted.

Pre-requisites.

  1. Java 7 or above.
  2. Gradle 2.3 or above.

How to import?

Eclipse IDE.
1. Clone/download as zip.
2. run > gradle eclipse This will create eclipse ide related files, now you can import as eclipse project.

How to Run?

Added Test class called DrugTest.java, Run as Junit test.

About

Demonistrates how to use "Foreign" generator strategy in Hibernate Framework. And also how to define One-to-One relation ship.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages