Michael Wyraz commented on Bug HHH-7688

I wonder if session really cannot be re-used after sql errors. The JavaDoc of session (http://docs.jboss.org/hibernate/core/4.1/javadocs/org/hibernate/Session.html) states:

If the Session throws an exception, the transaction must be rolled back and the session discarded. The internal state of the Session might not be consistent with the database after the exception occurs.

The Spring code disconnects the session at the end of a connection and calls session.clear() if the transaction fails. This should leave the session in a defined state because there's no state in the session that could differ from the database. Spring does even a clean reconnect here, so if everything is correctly cleared, the session should be re-usable. Of course to be sure, lot's of tests have to be done.

If I fix the thing above, my testcases (the one I provided, some others in the application) all run fine. Unfortunately there are only a few tests because there are only few cases where such conditions occur.

If it works to continue after failed transaction, it would allow to split big batches in many single transactions with almost no overhead (e.g. creating new sessions). This also possible with StatelessSession but with too many restrictions (e.g. no spring tx managament - https://jira.springsource.org/browse/SPR-2495 )

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira