This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate Problem while cascading multiple one to many relationships Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Problem while cascading multiple one to many relationships" Watch "Hibernate Problem while cascading multiple one to many relationships" New topic
Author

Hibernate Problem while cascading multiple one to many relationships

dhaval tamboli
Greenhorn

Joined: Aug 02, 2010
Posts: 25
Hi Guys,

I am not able to find out workaround of this issue.
Here is the case.
I am having hibernate xml mapping files for my tables.
I can add one-to-many relation in mapping and it works fine, but getting problem when child table has another one to many relationship.
e.g.
Segment is parent table and it has country as a child table. so i join country as


Everything is defined and its working fine here.
but now country table has a child table of states (with one to many relationship) so at com.bhn.service.segment.Country table i have list of states
and in country.hbm.xml file , I define it as



but I guess till country_id gets inserted, it tries to save state and throws error that Null value found in Not null column.
Not sure how to implement this.. after this I have cities table also as child of state with one to many relationship, so i m not sure how to implement this.

Thanks in advance


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate Problem while cascading multiple one to many relationships
 
Similar Threads
Can't map child List w/ composite ID
Hibernate Newbie - 1 to Many Relation Tutorial
help with hibernate
does Hibernate support one-to-one bidirectional in subclass?
Hibernate 3 Not Loading Values Into Child Set In JUnit Test