public class JdbcScope extends Object
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
protected static ThreadLocal<Map<String,SpincastConnection>> |
spincastConnectionsThreadLocal |
protected static ThreadLocal<Map<String,Connection>> |
spincastSpecificConnectionsThreadLocal |
| Constructor and Description |
|---|
JdbcScope(SpincastConnectionFactory spincastConnectionFactory) |
| Modifier and Type | Method and Description |
|---|---|
<T> T |
autoCommit(DataSource dataSource,
JdbcQueries<T> queries)
Executes the
queries with a Connection
guaranteed to not be closed during the process. |
Connection |
getConnectionInterceptor(org.aopalliance.intercept.MethodInvocation invocation)
Gets a Connection from a DataSource, or from the ThreadLocal cache
if we're inside a transaction.
|
protected String |
getDataSourceKey(DataSource dataSource) |
protected SpincastConnectionFactory |
getSpincastConnectionFactory() |
boolean |
isInTransactionScope() |
<T> T |
specificConnection(Connection connection,
DataSource dataSource,
ConnectionScope<T> connectionScope)
Starts a scope where only the specified connection
will be used (as long as
autoCommit(),
transactional(), transactional(),
withSpecificConnection() or withSpecificConnection()
are used... |
<T> T |
specificConnection(Connection connection,
DataSource dataSource,
JdbcQueries<T> queries)
Starts a scope where only the specified connection.
|
<T> T |
transactional(DataSource dataSource,
JdbcQueries<T> queries)
Executes the
queries in a transaction
by setting the Connection#setAutoCommit() property
to false. |
<T> T |
transactional(TransactionalScope<T> scope)
Starts a transactional scope.
|
protected final org.slf4j.Logger logger
protected static final ThreadLocal<Map<String,SpincastConnection>> spincastConnectionsThreadLocal
protected static final ThreadLocal<Map<String,Connection>> spincastSpecificConnectionsThreadLocal
@Inject public JdbcScope(SpincastConnectionFactory spincastConnectionFactory)
protected SpincastConnectionFactory getSpincastConnectionFactory()
protected String getDataSourceKey(DataSource dataSource)
public boolean isInTransactionScope()
public <T> T autoCommit(DataSource dataSource, JdbcQueries<T> queries)
queries with a Connection
guaranteed to not be closed during the process.
At the end of the process, the Connection will be
closed automatically.
Each query is going to be commited on the fly. Use
transactional(DataSource, JdbcQueries) or
a transactional(TransactionalScope) scope instead
if you need transactional support.
public <T> T specificConnection(Connection connection, DataSource dataSource, ConnectionScope<T> connectionScope)
autoCommit(),
transactional(), transactional(),
withSpecificConnection() or withSpecificConnection()
are used... Not a connection taken directly from a DataSource.)public <T> T specificConnection(Connection connection, DataSource dataSource, JdbcQueries<T> queries)
autoCommit(),
transactional(), transactional(),
withSpecificConnection() or withSpecificConnection()
are used... Not a connection taken directly from a DataSource.)public <T> T transactional(DataSource dataSource, JdbcQueries<T> queries)
queries in a transaction
by setting the Connection#setAutoCommit() property
to false.public <T> T transactional(TransactionalScope<T> scope)
public Connection getConnectionInterceptor(org.aopalliance.intercept.MethodInvocation invocation)
DataSource.getConnection().Copyright © 2018. All rights reserved.