open class IsolationLevelDataSourceAdapter : UserCredentialsDataSourceAdapter
An adapter for a target javax.sql.DataSource, applying the current Spring transaction's isolation level (and potentially specified user credentials) to every getConnection
call. Also applies the read-only flag, if specified.
Can be used to proxy a target JNDI DataSource that does not have the desired isolation level (and user credentials) configured. Client code can work with this DataSource as usual, not worrying about such settings.
Inherits the capability to apply specific user credentials from its superclass UserCredentialsDataSourceAdapter; see the latter's javadoc for details on that functionality (e.g. #setCredentialsForCurrentThread
).
WARNING: This adapter simply calls java.sql.Connection#setTransactionIsolation
and/or java.sql.Connection#setReadOnly
for every Connection obtained from it. It does, however, not reset those settings; it rather expects the target DataSource to perform such resetting as part of its connection pool handling. Make sure that the target DataSource properly cleans up such transaction state.
Author
Juergen Hoeller
Since
2.0.3
See Also
#setIsolationLevel#setIsolationLevelName#setUsername#setPassword
IsolationLevelDataSourceAdapter()
An adapter for a target javax.sql.DataSource, applying the current Spring transaction's isolation level (and potentially specified user credentials) to every Can be used to proxy a target JNDI DataSource that does not have the desired isolation level (and user credentials) configured. Client code can work with this DataSource as usual, not worrying about such settings. Inherits the capability to apply specific user credentials from its superclass UserCredentialsDataSourceAdapter; see the latter's javadoc for details on that functionality (e.g. WARNING: This adapter simply calls |
open fun setIsolationLevel(isolationLevel: Int): Unit
Specify the default isolation level to use for Connection retrieval, according to the JDBC java.sql.Connection constants (equivalent to the corresponding Spring org.springframework.transaction.TransactionDefinition constants). If not specified, the target DataSource's default will be used. Note that a transaction-specific isolation value will always override any isolation setting specified at the DataSource level. |
|
fun setIsolationLevelName(constantName: String): Unit
Set the default isolation level by the name of the corresponding constant in org.springframework.transaction.TransactionDefinition, e.g. "ISOLATION_SERIALIZABLE". If not specified, the target DataSource's default will be used. Note that a transaction-specific isolation value will always override any isolation setting specified at the DataSource level. |
open class WebSphereDataSourceAdapter : IsolationLevelDataSourceAdapter
DataSource implementation that delegates all calls to a WebSphere target DataSource, typically obtained from JNDI, applying a current isolation level and/or current user credentials to every Connection obtained from it. Uses IBM-specific API to get a JDBC Connection with a specific isolation level (and read-only flag) from a WebSphere DataSource (IBM code example). Supports the transaction-specific isolation level exposed by Usage example, defining the target DataSource as an inner-bean JNDI lookup (of course, you can link to any WebSphere DataSource through a bean reference): Thanks to Ricardo Olivieri for submitting the original implementation of this approach!
|