-->
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.  [ 5 posts ] 
Author Message
 Post subject: When is version property updated?
PostPosted: Wed Sep 08, 2004 8:07 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 6:23 pm
Posts: 39
When does Hibernate (2.1) update the version property of an object? Upon flush? Of course, I'm assuming that Hibernate keeps the object entity in sync with the DB by updating its version property with the new version set in the DB.
Oh, and that reminds me of another question: when using automatically generated ids, when does Hibernate set a new object's id? The moment save() returns or upon flush?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 08, 2004 8:41 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Try it and see. Your debugger is your friend :-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 12:12 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 6:23 pm
Posts: 39
Ha - my debugger = log.debug.
I've tried it a little, and am having a hard time pinning it down.
Please, if someone happens to know the answer to this question just jot it down real quick. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 1:58 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
version update occurs:
- on flush (so on commit too if flushmode = auto) if the versioned object has been updated (of course)
- when you work with detached object and use session.update()
- ...


why? what is your problem ?


note: for generated id ... it is when calling session.save()

don't forget all cascade aspect

and eclipse is a little bit better than ultraedit... easier to debug ;)

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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 09, 2004 3:07 pm 
Beginner
Beginner

Joined: Wed Feb 25, 2004 6:23 pm
Posts: 39
Thank you for the reply! We are using Hibernate persisted objects between application tiers (detach, serialize to other tier, other tier eventually sends changed objects back, etc). However, we are also trying to develop a solution where we don't have to retransmit the entire graph every time. This is complicated by the fact that the model (graph) mutates on save/update (on saves, the id is assigned, on updates, the version is changed) and so we have to keep these mutations in sync between tiers. Some applications can get away with the "load entire graph, let user make mods, save entire graph back to server - if user wants to continue editing, then reload entire graph from server" cycle, but that is not a workable option for us at the moment. We are now using an enterprise event system (ESB basically) whereby changes are transmitted live to other listening parties, thus keeping the tiers in sync. We just need to know the mechanics of when Hibernate mutates our objects so that we can properly sync those mutations with other tiers via the ESB.

Thanks!


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