-->
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.  [ 3 posts ] 
Author Message
 Post subject: Optimistic locking behaviour implementation
PostPosted: Mon Sep 18, 2006 7:53 am 
Newbie

Joined: Mon Sep 18, 2006 7:32 am
Posts: 2
Hi,
I am trying to implement optimistic concurrency behaviour in my web application which uses Hibernate in persistence layer and Struts in web layer with stateless EJB Business layer in between. I wanted to make use of StaleObjectStateException thrown by Hibernate whenever it finds version mismatch. We have used default setting of Flush mode as 'Auto'.

So, I caught the staleObject exception in my persistence manager (an abstarction over Hibernate API in our application and every save operation goes through it) and rethrow the same as some other checked exception and then propagate that exception till weblayer and reload the same page through Struts API. It is working fine for some uses cases.

However for other uses cases, hibernate auto flush kicks in by passing out persistence manager. And since staleObjectException thrown by hibernate is unchecked exception, EJB rollback the transcation. The issue is how best is to handle this situation (catching of StaleObjectException thrown by hibernate) and reload the same page through Struts API.
In general, any help in implementaing optimistic loacking behaviour in hibernate with struts API will be appreciated.

[/b]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 18, 2006 7:56 am 
Newbie

Joined: Wed Aug 03, 2005 11:04 am
Posts: 10
If you declare an Exception in the signature of your EJB it will not automatically roll back (look in the EJB specification). This even works for declared RuntimeExceptions. Be sure to understand how this works before using it!

Please rate this post.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 18, 2006 8:23 am 
Newbie

Joined: Mon Sep 18, 2006 7:32 am
Posts: 2
I don't want to bind the EJB layer with Hibernate specific API to break pluggablity of persistence implementation. That is why we have persistence manager as a abstraction over Hibernate.

I don't know how the people are implementing the Optimistic locking behaviour with Hibernate-Struts (reload of the same page after the StaleObjectStateException)


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