It's not a secret anymore!
The moose likes Object Relational Mapping and the fly likes Hibernate one-to-many relationship insert Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate one-to-many relationship insert" Watch "Hibernate one-to-many relationship insert" New topic

Hibernate one-to-many relationship insert

Nischal Tanna
Ranch Hand

Joined: Aug 19, 2003
Posts: 182
I am having a 1-to-many relationship btw Parent and child class....In the parent class i am something like

While inserting records in the db, my code is:

The above code inserts successfully in the parent db but does not insert in the child table

Any ideas?....I have tried "inverse=true" as well...Do i need to define a Many-to-one in child as well?
[ July 16, 2007: Message edited by: Nischal Tanna ]

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

What are your cascade options set to for this relationship? you will probably want it set to "save-update".


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Hibernate one-to-many relationship insert
jQuery in Action, 3rd edition