Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hiberante - one-to -many

 
gr Chinna
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai,i am using Hibernate3.0 one to many mapping...the problem is when i am using one to many,i am trying to map from parent to child..but this child has a foreign key which refers to parentID of parent table which is sequence generator..now if i want save the parent records,my parent id has to go to map the child,which is one -many here..how it is possible here..bocz of my parent will create . then only that id goes to child know...is it possible?or any other way........?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This is a typical case, of having parent/child relationship in Hibernate.
Hibernate takes care of ordering the sequence of sqls, so you need not worry about the FK violations. You just have to provide the appropriate <set> mapping in the hbm files
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic