public class OpenJpaDialect extends DefaultJpaDialect
JpaDialect
implementation for Apache OpenJPA.
Developed and tested against OpenJPA 2.2.Constructor and Description |
---|
OpenJpaDialect() |
Modifier and Type | Method and Description |
---|---|
Object |
beginTransaction(EntityManager entityManager,
TransactionDefinition definition)
This implementation invokes the standard JPA
Transaction.begin
method. |
ConnectionHandle |
getJdbcConnection(EntityManager entityManager,
boolean readOnly)
This implementation always returns
null ,
indicating that no JDBC Connection can be provided. |
protected org.apache.openjpa.persistence.OpenJPAEntityManager |
getOpenJPAEntityManager(EntityManager em)
Return the OpenJPA-specific variant of
EntityManager . |
cleanupTransaction, prepareTransaction, releaseJdbcConnection, translateExceptionIfPossible
public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException
DefaultJpaDialect
Transaction.begin
method. Throws an InvalidIsolationLevelException if a non-default isolation
level is set.
This implementation does not return any transaction data Object, since there
is no state to be kept for a standard JPA transaction. Hence, subclasses do not
have to care about the return value (null
) of this implementation
and are free to return their own transaction data Object.
beginTransaction
in interface JpaDialect
beginTransaction
in class DefaultJpaDialect
entityManager
- the EntityManager to begin a JPA transaction ondefinition
- the Spring transaction definition that defines semanticsJpaDialect.cleanupTransaction(java.lang.Object)
). May implement the
SavepointManager
interface.PersistenceException
- if thrown by JPA methodsSQLException
- if thrown by JDBC methodsTransactionException
- in case of invalid argumentsEntityTransaction.begin()
,
InvalidIsolationLevelException
,
DefaultJpaDialect.cleanupTransaction(java.lang.Object)
public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) throws PersistenceException, SQLException
DefaultJpaDialect
null
,
indicating that no JDBC Connection can be provided.getJdbcConnection
in interface JpaDialect
getJdbcConnection
in class DefaultJpaDialect
entityManager
- the current JPA EntityManagerreadOnly
- whether the Connection is only needed for read-only purposesreleaseJdbcConnection
,
or null
if no JDBC Connection can be retrievedPersistenceException
- if thrown by JPA methodsSQLException
- if thrown by JDBC methodsJpaDialect.releaseJdbcConnection(org.springframework.jdbc.datasource.ConnectionHandle, javax.persistence.EntityManager)
,
ConnectionHandle.getConnection()
,
SimpleConnectionHandle
,
JpaTransactionManager.setDataSource(javax.sql.DataSource)
,
NativeJdbcExtractor
protected org.apache.openjpa.persistence.OpenJPAEntityManager getOpenJPAEntityManager(EntityManager em)
EntityManager
.em
- the generic EntityManager
instanceEntityManager