Class IsolationLevelDataSourceAdapter

All Implemented Interfaces:
Wrapper, CommonDataSource, DataSource, InitializingBean

public class IsolationLevelDataSourceAdapter extends UserCredentialsDataSourceAdapter
An adapter for a target 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. UserCredentialsDataSourceAdapter.setCredentialsForCurrentThread(java.lang.String, java.lang.String)).

WARNING: This adapter simply calls Connection.setTransactionIsolation(int) and/or Connection.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.

Since:
2.0.3
Author:
Juergen Hoeller
See Also: