java.lang.Object | |||
↳ | org.springframework.jdbc.datasource.DelegatingDataSource | ||
↳ | org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter | ||
↳ | org.springframework.jdbc.datasource.IsolationLevelDataSourceAdapter |
Known Direct Subclasses |
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(String, String)
).
WARNING: This adapter simply calls
setTransactionIsolation(int)
and/or
setReadOnly(boolean)
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.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Specify the default isolation level to use for Connection retrieval,
according to the JDBC
Connection constants
(equivalent to the corresponding Spring
TransactionDefinition constants). | |||||||||||
Set the default isolation level by the name of the corresponding constant
in
TransactionDefinition , e.g. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Applies the current isolation level value and read-only flag
to the returned Connection.
| |||||||||||
Determine the current isolation level: either the transaction's
isolation level or a statically defined isolation level.
| |||||||||||
Determine the current read-only flag: by default,
the transaction's read-only hint.
| |||||||||||
Return the statically specified isolation level,
or
null if none. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter
| |||||||||||
From class
org.springframework.jdbc.datasource.DelegatingDataSource
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.sql.Wrapper
| |||||||||||
From interface
javax.sql.CommonDataSource
| |||||||||||
From interface
javax.sql.DataSource
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
|
Specify the default isolation level to use for Connection retrieval,
according to the JDBC Connection
constants
(equivalent to the corresponding Spring
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.
Set the default isolation level by the name of the corresponding constant
in 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.
constantName | name of the constant |
---|
IllegalArgumentException |
---|
Applies the current isolation level value and read-only flag to the returned Connection.
username | the username to use |
---|---|
password | the password to use |
SQLException |
---|
Determine the current isolation level: either the transaction's isolation level or a statically defined isolation level.
null
if noneDetermine the current read-only flag: by default, the transaction's read-only hint.
Return the statically specified isolation level,
or null
if none.