-->
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: optimistic locking doesn't work if you set version manually
PostPosted: Fri Mar 31, 2006 12:37 am 
Newbie

Joined: Mon Mar 27, 2006 7:46 pm
Posts: 17
I am working on a client/server app with a rich client. I have to deal with concurrent data access and am trying to do so with optimistic locking using versioning. Because I am using a thick client i use a DTOs to pass data back and forth between the server and client. I record the version id in the DTO. To perform an update I:
1)pass the dto back to the server
2) retrieve the hibernate domain object I am updating
3)update the domain object fields with the new values
4)update the version of the domain object to the original one i recorded in the dto
5)process the update

However when you update the domain object's version manually optimistic locking ceases to work. It is as if it ignores that value entirely, i am guessing it maybe just uses the cached version instead. This causes optimistic locking to fail.

I think this is a bug in hibernate. I see that this topic has been brought up several times on this forum for instance:

http://forum.hibernate.org/viewtopic.php?t=955121

I am hoping someone can explain why this does this or maybe this is a known bug?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 03, 2006 2:46 pm 
Newbie

Joined: Mon Mar 27, 2006 7:46 pm
Posts: 17
I am really hoping someone can explain to me why this doesn't work. I have searched the bug database and find that I am not the only one that finds this to be a problem, for instance:

http://opensource.atlassian.com/project ... se/HHH-348
http://opensource.atlassian.com/project ... e/HHH-1188

The replies to these bug reports obviously imply that this is intended to work like it does, but I don't see a clear explanation as to why. I don't want to submit another bug report on this same issue just to be rejected. I searched the forums heavily but can't find an answer.

It seems like changes to the version field are just ignored for the version check and used in the update. I don't understand why this would be, I would think this version field should be treated as a special field and manual changes to it would be considered on the version check. The pattern of having a DTO/view object layer is pretty common in rich clients and so I don't really see why this can be disregarded.

Clearly, I must be misunderstanding something and I would really appreciate a little help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 5:02 pm 
Newbie

Joined: Mon Mar 27, 2006 7:46 pm
Posts: 17
Can anyone explain this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 5:30 pm 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Hibernate does probably not expect that you change the version time stamp. In addition you do not use versioning in the expected manner.

You do not need to update the fields manually but just call session.update(yourObject)

Best Regards

Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 7:29 pm 
Newbie

Joined: Mon Mar 27, 2006 7:46 pm
Posts: 17
LaLiLuna wrote:
Hibernate does probably not expect that you change the version time stamp. In addition you do not use versioning in the expected manner.

You do not need to update the fields manually but just call session.update(yourObject)

Best Regards

Sebastian


I don't think you are reading my posts, this answer doesn't help at all.

Could someone PLEASE explain why my expected results do not occur?


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.