-->
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.  [ 9 posts ] 
Author Message
 Post subject: Cascade Updates - Version Nos
PostPosted: Tue Sep 21, 2004 9:06 am 
Newbie

Joined: Tue Sep 21, 2004 8:11 am
Posts: 6
This is a technical question about cascading updates and the way they affect version numbers on child/parent objects.

I've notice that with my current setup, which makes use of:
- integer version numbers
- optimistic locking on aforementioned version numbers
- dynamic updates
- cascade is set to all-delete-orphan

That if I update/create a child object, and saveOrUpdate() the parent object, then the version number for each object in the graph is updated, regardless of whether they were dirty or not.

[Note, the working scenario is detaching the objects from the session, and passing them up to a UI layer, and then back again.]

I was wondering whether it is possible to call update on a parent object, and yet only see the dirty child object (and it's version no) updated? Rather than the entire object graph.

Cheers, Owen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 9:42 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
this is explained in Hibernate in action. Do you have it?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 9:53 am 
Newbie

Joined: Tue Sep 21, 2004 8:11 am
Posts: 6
anthony wrote:
this is explained in Hibernate in action. Do you have it?


Unfortunately not. Maybe I'll get my hands on a copy.

Cheers, Owen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 21, 2004 10:47 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Christian and Gavin explained it very well in the book, just get it, you'll learn all you need

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject: I didn't really need the book did I?
PostPosted: Mon Oct 04, 2004 6:58 am 
Newbie

Joined: Tue Sep 21, 2004 8:11 am
Posts: 6
Hi Anthony,

I've got the book now. Read the associated sections, and discovered that all I need is to use 'select-before-update' so that the object isn't assummed to be dirty.

No doubt it is a good book, and will probably prove useful. But I don't think I needed to buy the book for what turned out to be a single paragraph.

Maybe next time you could provide the answer, when it's as obvious and simple to communicate as this would have been. Otherwise, people may think you're just trying to improve book sales.

Cheers, Owen


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 04, 2004 7:21 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
1- i'm not paid by "Hibernate in action" staff, i'm not paid at all, it is only free help here!
2- always giving a small answer to a complex issue is not good
3- for me cascade + versionning + locking is a complex feature.
4- By answering your particular use case, some other users would have used it everytime and select-before-update can be a performance killer.
5- Now you have THE book, you'll learn everything about concurrency, locking, versionning and even more....
6- Tell everybody how Hibernate in Action is a great book ;)


Regards,

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 05, 2004 7:37 am 
Newbie

Joined: Tue Sep 21, 2004 8:11 am
Posts: 6
Hi Anthony,

I wasn't meaning to agro in my last response, just wanted to point out that 'buy the book' kind of defeats the point of having the forum in some senses.

However, from your response I get the impression the you are suggesting there are alternative solutions. Perhaps I am missing something, but I couldn't see an alternative to 'select-before-update' given what I'm attempting to achieve.

Assuming that I still want to call update on the parent object , and only update the version numbers/data on those objects in the graph that are 'dirty' what other solutions are there?

Cheers, Owen


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 05, 2004 7:43 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
for update + versionning with detached instances (that is your case), if you don't want the version to be updated when the object has not been updated in the UI, you need 'select-before-update'. But that's the only use case i see.



[/u]

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 05, 2004 7:47 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
And in read-heavy applications (where data modification is negligible) this is mostly useful if you have DB triggers that shouldn't fire, etc.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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