wood burning stoves*
The moose likes Object Relational Mapping and the fly likes hiberante - one-to -many Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hiberante - one-to -many" Watch "hiberante - one-to -many" New topic
Author

hiberante - one-to -many

gr Chinna
Greenhorn

Joined: Jul 17, 2005
Posts: 2
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

Joined: Jul 20, 2005
Posts: 10146
    
165

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


[My Blog] [JavaRanch Journal]
 
GeeCON Prague 2014
 
subject: hiberante - one-to -many