Class OpenJpaDialect
- java.lang.Object
- org.springframework.orm.jpa.DefaultJpaDialect
- org.springframework.orm.jpa.vendor.OpenJpaDialect
- All Implemented Interfaces:
Serializable
,PersistenceExceptionTranslator
,JpaDialect
public class OpenJpaDialect extends DefaultJpaDialect
JpaDialect
implementation for Apache OpenJPA. Developed and tested against OpenJPA 2.2.- Since:
- 2.0
- Author:
- Juergen Hoeller, Costin Leau
- See Also:
- Serialized Form
Constructor Summary
Constructors Constructor Description OpenJpaDialect()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
beginTransaction(EntityManager entityManager, TransactionDefinition definition)
This implementation invokes the standard JPATransaction.begin
method.ConnectionHandle
getJdbcConnection(EntityManager entityManager, boolean readOnly)
This implementation always returnsnull
, indicating that no JDBC Connection can be provided.protected org.apache.openjpa.persistence.OpenJPAEntityManager
getOpenJPAEntityManager(EntityManager em)
Return the OpenJPA-specific variant ofEntityManager
.Methods inherited from class org.springframework.orm.jpa.DefaultJpaDialect
cleanupTransaction, prepareTransaction, releaseJdbcConnection, translateExceptionIfPossible
Constructor Detail
OpenJpaDialect
public OpenJpaDialect()
Method Detail
beginTransaction
public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException
Description copied from class:DefaultJpaDialect
This implementation invokes the standard JPATransaction.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.- Specified by:
beginTransaction
in interfaceJpaDialect
- Overrides:
beginTransaction
in classDefaultJpaDialect
- Parameters:
entityManager
- the EntityManager to begin a JPA transaction ondefinition
- the Spring transaction definition that defines semantics- Returns:
- an arbitrary object that holds transaction data, if any (to be passed into
JpaDialect.cleanupTransaction(java.lang.Object)
). May implement theSavepointManager
interface. - Throws:
PersistenceException
- if thrown by JPA methodsSQLException
- if thrown by JDBC methodsTransactionException
- in case of invalid arguments- See Also:
EntityTransaction.begin()
,InvalidIsolationLevelException
,DefaultJpaDialect.cleanupTransaction(java.lang.Object)
getJdbcConnection
public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) throws PersistenceException, SQLException
Description copied from class:DefaultJpaDialect
This implementation always returnsnull
, indicating that no JDBC Connection can be provided.- Specified by:
getJdbcConnection
in interfaceJpaDialect
- Overrides:
getJdbcConnection
in classDefaultJpaDialect
- Parameters:
entityManager
- the current JPA EntityManagerreadOnly
- whether the Connection is only needed for read-only purposes- Returns:
- a handle for the Connection, to be passed into
releaseJdbcConnection
, ornull
if no JDBC Connection can be retrieved - Throws:
PersistenceException
- if thrown by JPA methodsSQLException
- if thrown by JDBC methods- See Also:
JpaDialect.releaseJdbcConnection(org.springframework.jdbc.datasource.ConnectionHandle, javax.persistence.EntityManager)
,ConnectionHandle.getConnection()
,SimpleConnectionHandle
,JpaTransactionManager.setDataSource(javax.sql.DataSource)
,NativeJdbcExtractor
getOpenJPAEntityManager
protected org.apache.openjpa.persistence.OpenJPAEntityManager getOpenJPAEntityManager(EntityManager em)
Return the OpenJPA-specific variant ofEntityManager
.- Parameters:
em
- the genericEntityManager
instance- Returns:
- the OpenJPA-specific variant of
EntityManager