aspose file tools
The moose likes Object Relational Mapping and the fly likes Hibernate one-to-many relationship insert Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Hibernate one-to-many relationship insert" Watch "Hibernate one-to-many relationship insert" New topic
Author

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 ]

Thnx
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 16622

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

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: Hibernate one-to-many relationship insert
 
Threads others viewed
retrieving object hierarchy - many-to-one?
cascade vs inverse
Please help: What is the best strategy to update the DB using a detached object?
Error when saving relationship
what changes should i made in save method in one-to-many relationships
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture