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.  [ 8 posts ] 
Author Message
 Post subject: Fine control on children classes updates in one-to-many ...
PostPosted: Sun Dec 25, 2005 8:04 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
The major business object of my application has a few of one-to-many chirldren relationships. Those parent-children one-to-many relationships can be classified into two types. The first type, let's call it type A, is the object self attributes such as the colours of a cat. A cat can be a white-black colours' one, for instance. The second type, let's call it type B, is related to the object interactions in the system, such as bids of an auction item in the caveatemptor. When I want to update the business object, the type A children class objects also need to be updated, but not the type B.

How to have such fine control on the collection chirdren class object update operation? With the update method, the SQL statements generated by the HQL are updating the object correspondent table along with one table of its one children class objects, but not any other children class object tables. From the Hibernate mapping file, I can't tell the reason that the children table is updated, not not others.

Thanks for your inputs in advnace.


Top
 Profile  
 
 Post subject: cascade
PostPosted: Tue Dec 27, 2005 5:15 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
It is my understanding that you have two collection, childrenTypeA and childrenTypeB,
then in the mapping for childrenTypeA you would specify cascade='all'
and for childrenTypeB you would specify cascade='none'
http://www.hibernate.org/hib_docs/v3/re ... ns-mapping

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 6:58 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
Thanks for your reply, kgignatyev.

In fact, the object has more than two collection children objects. And in the all situations, the inverse is set to true and the cascade is set to all.


Top
 Profile  
 
 Post subject: cascade
PostPosted: Tue Dec 27, 2005 7:02 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Then you should set cascade="none" on the associations you do not want to update automatically.
cascade='all' tells H to update all reachable objects

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 7:09 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
You're right. But, the problem is that the cascade setting doesn't seem to relate to the SQL statements generated. As I had mentioned, only one child table update statement is created, but not any others with the same cascade setting.


Top
 Profile  
 
 Post subject: docs
PostPosted: Tue Dec 27, 2005 7:22 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
That is how much I can help without seeing the exact mapping documents, classes, and caller code, all the stuff from H problem report template :)

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 7:34 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
When I run into this issue, I first tried to figure any differences among the settings in the mapping file since the class has five collection children classes and only one child class objects got updated. I fell on this attempt. Otherwise, I would bother people in this forum. Thx.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 10:04 pm 
Regular
Regular

Joined: Wed Aug 25, 2004 7:40 pm
Posts: 65
I just completed my test with a modified cascade setttings. The collection children class objects are not updated with the "none" setting, but neither those with "all" settings when the parent class object is updating.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.