Description
Philippe Marschall opened SPR-15210 and commented
Previously (with the 9i and 10g) Oracle JDBC driver read only Spring transactions resulted in read only Oracle transactions. With the 12c Oracle JDBC driver this is no longer the case (I'm unsure about the behavior of the 11g driver).
Read only Oracle transactions are a nice feature because the give you read consistency including repeatable reads.
Read only Spring transactions used to create read only Oracle transactions because the DataSourceTransactionManager
calls Connection.setReadOnly(true)
. With old versions of the Oracle JDBC driver this used to create a read only transaction. This was a bug in the driver that was later corrected. The purpose of the Connection.setReadOnly(true)
is to create a read only connection, not a read only transaction.
Unfortunately JDBC offers no portable way to create a read only transaction.
Oracle, PostgreS and MySQL all require a variant of
SET TRANSACTION READ ONLY
with possibly an isolation level. This can also be done in a START TRANSACTION
.
We considered making a subclass of DataSourceTransactionManager
but the requirement to register a DataSourceTransactionObject
which is private makes this tricky. Also DataSourceUtils.prepareConnectionForTransaction
does not offer an easy way to plug in vendor specific behavior.
Issue Links:
- Rollback of transaction participating in nested transaction should not enforce rollback of global transaction [SPR-6568] #11234 Rollback of transaction participating in nested transaction should not enforce rollback of global transaction
- Database.SQL_SERVER should set more recent Hibernate dialect with Spring 4.3.x [SPR-15255] #19820 Database.SQL_SERVER should set more recent Hibernate dialect with Spring 4.3.x