-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: @OneToMany updated ALL child versions when parent persisted?
PostPosted: Mon Mar 27, 2006 12:46 pm 
Newbie

Joined: Mon Jan 23, 2006 11:04 am
Posts: 7
hbm 3.1 core / 3.b7 ann

hbm is cascading updates on all children in a birdirectional @OneToMany when an attribute of the parent is updated....i.e update one parent with 20 child objects in a collection when no attributes of the children have changed, i.e. 21 records updated on the database whereas I was expecting only the parent records change to be persisted.

hbm compares by value, even if CascadeType=PERSIST is set on the parent getChildren(), I would expect the changed values in the children to be persisted if any child attributes have changed which they had not?

any explanation welcomed
thks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 5:27 am 
Newbie

Joined: Mon Jan 23, 2006 11:04 am
Posts: 7
please ignore ...user error !
;-)


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 15, 2006 12:19 pm 
Senior
Senior

Joined: Tue Mar 09, 2004 2:38 pm
Posts: 141
Location: Lowell, MA USA
Just curious what your user error was? I am experiencing a similar issue when I add a new Address to a previously persistent User instance. When I add the Address to the User and then pass it to Session.persist(), I see that Hibernate inserts the new Address, but also loads up all of the other assocations - which are never used or called in the transaction. This is not the behavior when I was seeing when using the XML mapping files so I'm very curious is there is a simple solution. Thanks!

Ryan-

_________________
Ryan J. McDonough
http://damnhandy.com

Please remember to rate!


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 02, 2006 8:12 am 
Newbie

Joined: Mon Jan 23, 2006 11:04 am
Posts: 7
Ryan,
hbm does not compare by value for collections.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 02, 2006 8:38 am 
Senior
Senior

Joined: Tue Mar 09, 2004 2:38 pm
Posts: 141
Location: Lowell, MA USA
Well, it depends on the type of collection used. I happen to be using a Set and the values will be compared as to not allow duplicate values. If Hibernate needs to load the items in the Addresses Set of my User instance in order to identify duplicate instances. That is the expected behavior and I understand that.

However, what I am seeing is that other Sets such as the User's phone numbers, email addresses and other one-to-many collections are being fully initialzed when I add an Address to the User and pass the user to Session.persist(). This is behavior that I have not encountered when using the XML mappings and calling Session.update().

Ryan-

_________________
Ryan J. McDonough
http://damnhandy.com

Please remember to rate!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 2:22 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
this is fixed in later versions

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 25, 2006 10:28 pm 
Senior
Senior

Joined: Tue Mar 09, 2004 2:38 pm
Posts: 141
Location: Lowell, MA USA
Thanks for the info Emmanuel! I'll be sure to check out the latest.

Ryan-

_________________
Ryan J. McDonough
http://damnhandy.com

Please remember to rate!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.