public.javadoc.org.spincast.plugins.jdbc.JdbcScope.html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spincast-website Show documentation
Show all versions of spincast-website Show documentation
Source code for the https://www.spincast.org website.
JdbcScope (org.spincast:spincast-framework 1.13.0 API)
org.spincast.plugins.jdbc
Class JdbcScope
- java.lang.Object
-
- org.spincast.plugins.jdbc.JdbcScope
-
public class JdbcScope
extends Object
-
-
Field Summary
Fields
Modifier and Type
Field and Description
protected static org.slf4j.Logger
logger
protected static ThreadLocal<Map<String,SpincastConnection>>
spincastConnectionsThreadLocal
protected static ThreadLocal<Map<String,Connection>>
spincastSpecificConnectionsThreadLocal
-
Constructor Summary
Constructors
Constructor and Description
JdbcScope(SpincastConnectionFactory spincastConnectionFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods
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.
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
spincastConnectionsThreadLocal
protected static final ThreadLocal<Map<String,SpincastConnection>> spincastConnectionsThreadLocal
-
spincastSpecificConnectionsThreadLocal
protected static final ThreadLocal<Map<String,Connection>> spincastSpecificConnectionsThreadLocal
-
Constructor Detail
-
JdbcScope
@Inject
public JdbcScope(SpincastConnectionFactory spincastConnectionFactory)
-
Method Detail
-
getSpincastConnectionFactory
protected SpincastConnectionFactory getSpincastConnectionFactory()
-
getDataSourceKey
protected String getDataSourceKey(DataSource dataSource)
-
isInTransactionScope
public boolean isInTransactionScope()
-
autoCommit
public <T> T autoCommit(DataSource dataSource,
JdbcQueries<T> queries)
Executes the 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.
-
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 as autoCommit()
,
transactional()
, transactional()
,
withSpecificConnection()
or withSpecificConnection()
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 as autoCommit()
,
transactional()
, transactional()
,
withSpecificConnection()
or withSpecificConnection()
are used... Not a connection taken directly from a DataSource.)
-
transactional
public <T> T transactional(DataSource dataSource,
JdbcQueries<T> queries)
Executes the queries
in a transaction
by setting the Connection#setAutoCommit()
property
to false
.
-
transactional
public <T> T transactional(TransactionalScope<T> scope)
Starts a transactional scope.
-
getConnectionInterceptor
public Connection getConnectionInterceptor(org.aopalliance.intercept.MethodInvocation invocation)
Gets a Connection from a DataSource, or from the ThreadLocal cache
if we're inside a transaction.
This method is called by AOP intercepting
DataSource.getConnection()
.
Copyright © 2019. All rights reserved.