public class JdbcScope extends Object
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
protected static ThreadLocal<Map<String,SpincastConnection>> |
spincastConnectionsThreadLocal |
| 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 |
getConnection(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 |
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
@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 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 getConnection(org.aopalliance.intercept.MethodInvocation invocation)
Copyright © 2017. All rights reserved.