Hello, I'm developing an application and am using the session-per-request pattern. During the request process I need to commit the transaction, and thus flush the hibernate session, at various points (this is being accomplished by the Spring framework and AOP).
A problem arises when an exception is thrown during a flush operation. At this point I am aware that the session should be "discarded"; however, after looking at the Spring code I do not see that they are doing this for me, and it looks like it would be a heroic feat to alter the code to actually discard the old session and insert a new one at the necessary points. I have found a solution that will allow me to run a session.clear() at the appropriate points.
So...my question is: After an exception on a session.flush() operation, will a session.clear() be sufficient to guard against any invalid hibernate session state and/or data reads/writes/commits? If not, it's back to the drawing board...
Thanks in advance for any help! Dave Wolff
|