The hibernate documentation states the following:
The configuration parameter hibernate.connection.release_mode is used to specify which release mode to use. The possible values: *auto (the default) - equivalent to after_transaction in the current release. It is rarely a good idea to change this default behavior as failures due to the value of this setting tend to indicate bugs and/or invalid assumptions in user code. *on_close - says to use ConnectionReleaseMode.OnClose. This setting is left for backwards compatibility, but its use is highly discouraged. ...
I have created an integration test that provokes a StaleObjectException by opening two sessions at the same time and manipulating the same entity. To ensure that the test rolls-back everything upon completion, the test content is placed within a TransactionScope; this causes distributed transactions to kick in because two sessions will open a db connection against the same ambient transaction. I want to change the default ConnectionReleaseMode setting to "OnClose", but as stated above, the documentation does not recommend this. Can anyone explain why its not a good idea to change the default behaviour?