wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Cascading update problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Cascading update problem" Watch "Cascading update problem" New topic
Author

Cascading update problem

John Utting
Greenhorn

Joined: Mar 05, 2002
Posts: 16
Hi, I am doing some little tests to understand some of the behaviour of hibernate (v3.1) and would like some advice.

I have a bidirection parent child relationship as follows:

parent.hbm.xml




child.hbm.xml




Parent.java




I open a session and get a parent from the database and any chilren are eagerly fetched (ignore the fact that i am eagerly loading a collection this is for a test only). Session closed.

I then create a new child and add it to the parent. Then, in a new Session, update the parent object, resulting in the transient child being persisted. All well and good.

The behaviour i am also seeing is that hibernate is updating all the children even though their state has not changed.

I understand that instead of updating the parent i could save the child and this would prevent the other children being updated. What i would like to know is their a way of configuring hibernate or the relationship so that i can update the parent and persist new children without hibernate firing updates on all the other children.

Any help would be greatly appreciated.

Thanks
John


SCJP 1.4 SCWCD...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cascading update problem
 
Similar Threads
when save parent, the children do not get saved
Parent-Child Mapping with Hibernate 2.0
what changes should i made in save method in one-to-many relationships
Error when saving relationship
list objects present in hibernate session