| org.springframework.orm.jpa.JpaDialect
All known Subclasses: org.springframework.orm.jpa.DefaultJpaDialect,
Method Summary | |
Object | beginTransaction(EntityManager entityManager, TransactionDefinition definition) Begin the given JPA transaction, applying the semantics specified by the
given Spring transaction definition (in particular, an isolation level
and a timeout). | void | cleanupTransaction(Object transactionData) Clean up the transaction via the given transaction data. | EntityManagerFactoryPlusOperations | getEntityManagerFactoryPlusOperations(EntityManagerFactory rawEntityManager) Return an EntityManagerFactoryPlusOperations implementation for
the given raw EntityManagerFactory. | EntityManagerPlusOperations | getEntityManagerPlusOperations(EntityManager rawEntityManager) Return an EntityManagerPlusOperations implementation for
the given raw EntityManager. | ConnectionHandle | getJdbcConnection(EntityManager entityManager, boolean readOnly) Retrieve the JDBC Connection that the given JPA EntityManager uses underneath,
if accessing a relational database. | Object | prepareTransaction(EntityManager entityManager, boolean readOnly, String name) Prepare a JPA transaction, applying the specified semantics. | void | releaseJdbcConnection(ConnectionHandle conHandle, EntityManager entityManager) Release the given JDBC Connection, which has originally been retrieved
via getJdbcConnection . | boolean | supportsEntityManagerFactoryPlusOperations() Return whether the EntityManagerFactoryPlus(Operations) interface is
supported by this provider. | boolean | supportsEntityManagerPlusOperations() Return whether the EntityManagerPlus(Operations) interface is
supported by this provider. |
beginTransaction | Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException(Code) | | Begin the given JPA transaction, applying the semantics specified by the
given Spring transaction definition (in particular, an isolation level
and a timeout). Called by JpaTransactionManager on transaction begin.
An implementation can configure the JPA Transaction object and then
invoke begin , or invoke a special begin method that takes,
for example, an isolation level.
An implementation can apply the read-only flag as flush mode. In that case,
a transaction data object can be returned that holds the previous flush mode
(and possibly other data), to be reset in cleanupTransaction .
It may also apply the read-only flag and isolation level to the underlying
JDBC Connection before beginning the transaction.
Implementations can also use the Spring transaction name, as exposed by the
passed-in TransactionDefinition, to optimize for specific data access use cases
(effectively using the current transaction name as use case identifier).
This method also allows for exposing savepoint capabilities if supported by
the persistence provider, through returning an Object that implements Spring's
org.springframework.transaction.SavepointManager interface.
JpaTransactionManager will use this capability if needed.
Parameters: entityManager - the EntityManager to begin a JPA transaction on Parameters: definition - the Spring transaction definition that defines semantics an arbitrary object that holds transaction data, if any(to be passed into JpaDialect.cleanupTransaction). May implement theorg.springframework.transaction.SavepointManager interface. throws: javax.persistence.PersistenceException - if thrown by JPA methods throws: java.sql.SQLException - if thrown by JDBC methods throws: org.springframework.transaction.TransactionException - in case of invalid arguments See Also: JpaDialect.cleanupTransaction See Also: javax.persistence.EntityTransaction.begin See Also: org.springframework.jdbc.datasource.DataSourceUtils.prepareConnectionForTransaction |
cleanupTransaction | void cleanupTransaction(Object transactionData)(Code) | | Clean up the transaction via the given transaction data. Called by
JpaTransactionManager and EntityManagerFactoryUtils on transaction cleanup.
An implementation can, for example, reset read-only flag and
isolation level of the underlying JDBC Connection. Furthermore,
an exposed data access use case can be reset here.
Parameters: transactionData - arbitrary object that holds transaction data, if any(as returned by beginTransaction or prepareTransaction) See Also: JpaDialect.beginTransaction See Also: org.springframework.jdbc.datasource.DataSourceUtils.resetConnectionAfterTransaction |
getEntityManagerFactoryPlusOperations | EntityManagerFactoryPlusOperations getEntityManagerFactoryPlusOperations(EntityManagerFactory rawEntityManager)(Code) | | Return an EntityManagerFactoryPlusOperations implementation for
the given raw EntityManagerFactory. This operations object can be
used to serve the additional operations behind a proxy that
implements the EntityManagerFactoryPlus interface.
Parameters: rawEntityManager - the raw provider-specific EntityManagerFactory the EntityManagerFactoryPlusOperations implementation |
getEntityManagerPlusOperations | EntityManagerPlusOperations getEntityManagerPlusOperations(EntityManager rawEntityManager)(Code) | | Return an EntityManagerPlusOperations implementation for
the given raw EntityManager. This operations object can be
used to serve the additional operations behind a proxy that
implements the EntityManagerPlus interface.
Parameters: rawEntityManager - the raw provider-specific EntityManagerFactory the EntityManagerFactoryPlusOperations implementation |
getJdbcConnection | ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) throws PersistenceException, SQLException(Code) | | Retrieve the JDBC Connection that the given JPA EntityManager uses underneath,
if accessing a relational database. This method will just get invoked if actually
needing access to the underlying JDBC Connection, usually within an active JPA
transaction (for example, by JpaTransactionManager). The returned handle will
be passed into the releaseJdbcConnection method when not needed anymore.
This strategy is necessary as JPA 1.0 does not provide a standard way to retrieve
the underlying JDBC Connection (due to the fact that a JPA implementation might not
work with a relational database at all).
Implementations are encouraged to return an unwrapped Connection object, i.e.
the Connection as they got it from the connection pool. This makes it easier for
application code to get at the underlying native JDBC Connection, like an
OracleConnection, which is sometimes necessary for LOB handling etc. We assume
that calling code knows how to properly handle the returned Connection object.
In a simple case where the returned Connection will be auto-closed with the
EntityManager or can be released via the Connection object itself, an
implementation can return a SimpleConnectionHandle that just contains the
Connection. If some other object is needed in releaseJdbcConnection ,
an implementation should use a special handle that references that other object.
Parameters: entityManager - the current JPA EntityManager Parameters: readOnly - whether the Connection is only needed for read-only purposes a handle for the JDBC Connection, to be passed intoreleaseJdbcConnection , or null if no JDBC Connection can be retrieved throws: javax.persistence.PersistenceException - if thrown by JPA methods throws: java.sql.SQLException - if thrown by JDBC methods See Also: JpaDialect.releaseJdbcConnection See Also: org.springframework.jdbc.datasource.ConnectionHandle.getConnection See Also: org.springframework.jdbc.datasource.SimpleConnectionHandle See Also: JpaTransactionManager.setDataSource See Also: org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor |
prepareTransaction | Object prepareTransaction(EntityManager entityManager, boolean readOnly, String name) throws PersistenceException(Code) | | Prepare a JPA transaction, applying the specified semantics. Called by
EntityManagerFactoryUtils when enlisting an EntityManager in a JTA transaction.
An implementation can apply the read-only flag as flush mode. In that case,
a transaction data object can be returned that holds the previous flush mode
(and possibly other data), to be reset in cleanupTransaction .
Implementations can also use the Spring transaction name, as exposed by the
passed-in TransactionDefinition, to optimize for specific data access use cases
(effectively using the current transaction name as use case identifier).
Parameters: entityManager - the EntityManager to begin a JPA transaction on Parameters: readOnly - whether the transaction is supposed to be read-only Parameters: name - the name of the transaction (if any) an arbitrary object that holds transaction data, if any(to be passed into cleanupTransaction) throws: javax.persistence.PersistenceException - if thrown by JPA methods See Also: JpaDialect.cleanupTransaction |
releaseJdbcConnection | void releaseJdbcConnection(ConnectionHandle conHandle, EntityManager entityManager) throws PersistenceException, SQLException(Code) | | Release the given JDBC Connection, which has originally been retrieved
via getJdbcConnection . This should be invoked in any case,
to allow for proper release of the retrieved Connection handle.
An implementation might simply do nothing, if the Connection returned
by getJdbcConnection will be implicitly closed when the JPA
transaction completes or when the EntityManager is closed.
Parameters: conHandle - the JDBC Connection handle to release Parameters: entityManager - the current JPA EntityManager throws: javax.persistence.PersistenceException - if thrown by JPA methods throws: java.sql.SQLException - if thrown by JDBC methods See Also: JpaDialect.getJdbcConnection |
|
|