Package org.spincast.plugins.jdbc
Class JdbcScope
java.lang.Object
org.spincast.plugins.jdbc.JdbcScope
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final org.slf4j.Logger
protected static final ThreadLocal<Map<String,
SpincastConnection>> protected static final ThreadLocal<Map<String,
Connection>> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
autoCommit
(DataSource dataSource, JdbcQueries<T> queries) Executes thequeries
with a Connection guaranteed to not be closed during the process.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
boolean
<T> T
specificConnection
(Connection connection, DataSource dataSource, ConnectionScope<T> connectionScope) Starts a scope where only the specified connection will be used (as long asautoCommit()
,transactional()
,transactional()
,withSpecificConnection()
orwithSpecificConnection()
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 thequeries
in a transaction by setting theConnection#setAutoCommit()
property tofalse
.<T> T
transactional
(TransactionalScope<T> scope) Starts a transactional scope.
-
Field Details
-
logger
protected static final org.slf4j.Logger logger -
spincastConnectionsThreadLocal
-
spincastSpecificConnectionsThreadLocal
-
-
Constructor Details
-
JdbcScope
-
-
Method Details
-
getSpincastConnectionFactory
-
getDataSourceKey
-
isInTransactionScope
public boolean isInTransactionScope() -
autoCommit
Executes thequeries
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 atransactional(TransactionalScope)
scope instead if you need transactional support. -
specificConnection
public <T> T specificConnection(Connection connection, DataSource dataSource, ConnectionScope<T> connectionScope) Starts a scope where only the specified connection will be used (as long asautoCommit()
,transactional()
,transactional()
,withSpecificConnection()
orwithSpecificConnection()
are used... Not a connection taken directly from a DataSource.) -
specificConnection
public <T> T specificConnection(Connection connection, DataSource dataSource, JdbcQueries<T> queries) Starts a scope where only the specified connection. will be used (as long asautoCommit()
,transactional()
,transactional()
,withSpecificConnection()
orwithSpecificConnection()
are used... Not a connection taken directly from a DataSource.) -
transactional
Executes thequeries
in a transaction by setting theConnection#setAutoCommit()
property tofalse
. -
transactional
Starts a transactional scope. -
getConnectionInterceptor
Gets a Connection from a DataSource, or from the ThreadLocal cache if we're inside a transaction. This method is called by AOP interceptingDataSource.getConnection()
.
-