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]
|