aspose file tools
The moose likes Object Relational Mapping and the fly likes Hibernate One-to-Many foreign key Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Hibernate One-to-Many foreign key" Watch "Hibernate One-to-Many foreign key" New topic
Author

Hibernate One-to-Many foreign key

Ally Cavs
Ranch Hand

Joined: Aug 25, 2008
Posts: 75
Hi Guys

I have a parent-child unidirection relationship.
parent mapptng



on the child mapping I have the follwoing mapping


I do a hibernate session saveOrUpdate on a new parent and new children.
My parent will have mutilple child objects in its child List
SQL output shows parent inserted, children inserted and the foreign key(PARENT_ID) on all the children is updated.
The returned object has all primary keys now set (parent and children primaru keys) yet all Java Child POJO foreign key attribute (parentID) is still NULL.
Yet i query the database and i see the foreign key is populated

I have to refresh my parent object for the foreign key attribute on the children to be populated.
Any ideas on why initially the Java Child POJO parentID attribute is NULL
I have to do teh followingto get the foreign key attribute to refresh:


Any help is much appreciated

Thanks
Alan
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Hibernate One-to-Many foreign key
 
Similar Threads
Hibernate 3.0 : Where am I going wrong?
Problem in inserting a foreign key
what changes should i made in save method in one-to-many relationships
Recursive Mapping of collections
hibernate get parent based on children