-->
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.  [ 2 posts ] 
Author Message
 Post subject: Spring Hibernate Optimistic Locking Versioning Issue
PostPosted: Sun Jan 17, 2010 3:16 am 
Newbie

Joined: Sun Jan 17, 2010 3:13 am
Posts: 1
Hello everyone,

I am facing problem while implementing Concurrency Control through Hibernate version tag.
I will be not able to put code here due to some policies, but I will try to explain the problem.

We are using MVC architecture.
So when page is displayed, we sent the version number with other fields to html page. E.g. version = 1 when User A has opened it.
Same way, User B opened the same page and version =1 is stored as hidden field.

After that, User A saved the data and version number is increased to 2 in respective column of table and the same version is again sent back to page.
When User B saved the date with version 1, it saves the data without throwing Hibernate Optimistic Locking Exception.

All hibernate related settings are in place.
I was trying few things and was able to get exception when trying save new domain object.
Let me explain more here....
I had tried to UPDATE my object two ways from Business/Service Layer.
I have 30 columns in my table and I only need to save 5 columns from this page and other columns from other pages.
Transaction is applied on all BO methods through Spring AOP.

1.
Got Transfer Object (TO) from Controller.
Got Latest Domain Object from DAO.
Populate 5 updated columns and version in Domain Object.


This didn't throw any Exception while updating if the version is different in domain object and in database.

2.
Got Transfer Object (TO) from Controller.
Got Latest Domain Object from DAO.
Created New Domain Object using Constructor.
Populated 5 updated fields and version in new Domain Object from Transfer Object.
Rest of the fields copied from latest domain object retrieved from Database.


This throws the Hibernate Locking Exception.

I am updating the version property of Domain Object in both the cases, but in 1st case, it is not throwing an exception.
While in second case, it throws the exception.

Could you please throw some light on this?

I am using HibernateDaoSupport and HibernateTransactionManager of Spring.

Thanks in advance.

Regards,
Nilesh Kamani


Top
 Profile  
 
 Post subject: Re: Spring Hibernate Optimistic Locking Versioning Issue
PostPosted: Thu Aug 12, 2010 1:27 pm 
Beginner
Beginner

Joined: Mon Aug 23, 2004 12:44 am
Posts: 25
I'm facing the same problem. Did you find the cause ? How did you solve it ? Thanks, EDH


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