emmanuel wrote:
I don't get it,
If the driver is set to autocommit=true, then it's changed and restored
If the driver is set to autocommit=false, then it's fine, nothing to do.
What am I missing ?
Hmm.. I wasn't clear enough ;-)
The problem is my application REQUIRES autocommit to be false - otherwise my transaction strategy may fail.
Suppose the JDBC driver is set to autocommit=true:
The JDBCTransaction will turn it off until commit or rollback, and restore it to true after.
In our system, a session may still be open after a transaction rollback (which is done at the first exception thrown by a service). A this point, the JDBCTransaction will set autocommit=true again, causing changes made after the rollback to be flushed and persisted when the session is closed.
In this case, these changes are not covered by any transaction anymore - and I wont to be sure they wont get to the database.
The easiest solution was to set autocommit=false, so they will be discarded by the database itself.
My point was there is no *explicit* item in the Hibernate configuration file that let the user configure the autocommit behaviour.
This seems important to me since it may have big impact on how well the application behaves.
Moreover, it seems that many people get caught with the same kind of problem (cfr. search forum on autocommit). An explicit configuration item in hibernate.properties may be an additional hint to developper and may help to reduce mistakes.
Finally, we have been caught by this issue when switching to another database having different default settings regarding the autocommit... And you don't notice it until you start having dirty records in your database!
Is my explanation better this time (made great efforts to improve my English ;)