Hi all,
Given that Hibernate exceptions are not recoverable, how do you solve this common problem ?
A single session is opened in service layer. Then :
1. load an entity 2. execute some business process with this entity 3a. if success, set entity status to "Success" 3b. if any exception is thrown, set entity status to "Failed" 4. Save entity and commit
In step 3b, if we get an Hibernate exception, session cannot be reused and step 4 is not possible. But I do need to set the entity status to "Failed".
What do you suggest to solve this ? One session for the business process, and another session to set the status ? Knowing that I'm using the OpenSessionInView pattern, I think I'm gonna have fun with this one...
Thanks for your suggestions
JCG
|