-->
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: How to synchronize a client-side object's version number?
PostPosted: Tue Nov 22, 2005 10:57 pm 
Beginner
Beginner

Joined: Mon Nov 21, 2005 6:38 pm
Posts: 30
Location: New Zealand
Hi,

I have a client that communicates to a long-running NH session via a web service, and I am using versioning to enforce optimistic locking.

When an object is successfully updated in the DB, its version number is incremented, which then renders the client-side version stale. So the client-side version number needs to be synchronized, otherwise the client will not be able to do any more updates.

The obvious solution is to send the entire updated object back down to the client to replace the original one, but this could be cumbersome depending on the complexity of the object. I had thought about simply incrementing the version in the client if the update is successful, but the version number is not updated unless the object differs from the one in the NH session.

So I was wondering if anyone had any thoughts on how to handle synchronizing version numbers in an efficient manner?

TIA,
Dean.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 9:17 pm 
Beginner
Beginner

Joined: Tue Oct 25, 2005 2:44 am
Posts: 20
Location: Sydney, Australia
I'm not particularly clever with NH yet and not sure of your design decision, but couldn't you place an NHibernate interceptor on the object and keep a flag that an update has occurred? That flag would then tell you to update the version number on the client. Or alternatively just re-retrieve the object and return the updated version number every time?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 23, 2005 11:57 pm 
Beginner
Beginner

Joined: Mon Nov 21, 2005 6:38 pm
Posts: 30
Location: New Zealand
Kerry,

Thanks for the suggestion about interceptors, I think that might work.
When a particular object is updated, I could record the fact, and then send a list of updated objects back to the client so that it can update the version numbers.

The only other alternative I think is, as you say, to send back the entire object itself but this could have performance issues if objects are bulky.
:D


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 26, 2005 9:28 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
I hope that you understand that you are working around the problem (and it can became a problem later).

If you are doing this only for "performance" reasons, make sure that it is really a performance issue before doing an "optimization".

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 28, 2005 9:29 pm 
Beginner
Beginner

Joined: Mon Nov 21, 2005 6:38 pm
Posts: 30
Location: New Zealand
KPixel,

Thanks for the warning.
After some discussion, we have decided that we will initially return the entire (updated) object to the client so that the version numbers can be kept in synch.
As you say, if this method turns out to be causing performance issues, then we will go the extra step and put in interceptors.


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.