Class EclipseLinkJpaDialect
- All Implemented Interfaces:
- Serializable,- PersistenceExceptionTranslator,- JpaDialect
JpaDialect implementation for Eclipse
 Persistence Services (EclipseLink). Compatible with EclipseLink 3.0/4.0.
 By default, this dialect acquires an early EclipseLink transaction with an
 early JDBC Connection for non-read-only transactions. This allows for mixing
 JDBC and JPA operations in the same transaction, with cross visibility of
 their impact. If this is not needed, set the "lazyDatabaseTransaction" flag to
 true or consistently declare all affected transactions as read-only.
 As of Spring 4.1.2, this will reliably avoid early JDBC Connection retrieval
 and therefore keep EclipseLink in shared cache mode.
 
NOTE: This dialect supports custom isolation levels with limitations.
 Consistent isolation level handling is only guaranteed when all Spring transaction
 definitions specify a concrete isolation level, and as of 6.0.10 also when using
 the default isolation level with non-readOnly and non-lazy transactions. See the
 "lazyDatabaseTransaction" javadoc for details.
- Since:
- 2.5.2
- Author:
- Juergen Hoeller
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbeginTransaction(EntityManager entityManager, TransactionDefinition definition) This implementation invokes the standard JPATransaction.beginmethod.getJdbcConnection(EntityManager entityManager, boolean readOnly) This implementation always returnsnull, indicating that no JDBC Connection can be provided.voidsetLazyDatabaseTransaction(boolean lazyDatabaseTransaction) Set whether to lazily start a database resource transaction within a Spring-managed EclipseLink transaction.Methods inherited from class org.springframework.orm.jpa.DefaultJpaDialectcleanupTransaction, prepareTransaction, releaseJdbcConnection, translateExceptionIfPossible
- 
Constructor Details- 
EclipseLinkJpaDialectpublic EclipseLinkJpaDialect()
 
- 
- 
Method Details- 
setLazyDatabaseTransactionpublic void setLazyDatabaseTransaction(boolean lazyDatabaseTransaction) Set whether to lazily start a database resource transaction within a Spring-managed EclipseLink transaction.By default, read-only transactions are started lazily but regular non-read-only transactions are started early. This allows for reusing the same JDBC Connection throughout an entire EclipseLink transaction, for enforced isolation and consistent visibility with JDBC access code working on the same DataSource. Switch this flag to "true" to enforce a lazy database transaction begin even for non-read-only transactions, allowing access to EclipseLink's shared cache and following EclipseLink's connection mode configuration, assuming that isolation and visibility at the JDBC level are less important. NOTE: Lazy database transactions are not guaranteed to work reliably in combination with custom isolation levels. Use read-only as well as this lazy flag with care. If other transactions use custom isolation levels, it is not recommended to use read-only and lazy transactions at all. Otherwise, you may see non-default isolation levels used during read-only or lazy access. If this is not acceptable, don't use read-only and lazy next to custom isolation levels in potentially concurrent transactions. - See Also:
- 
- UnitOfWork.beginEarlyTransaction()
- TransactionDefinition.isReadOnly()
- TransactionDefinition.getIsolationLevel()
 
 
- 
beginTransaction@Nullable public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException Description copied from class:DefaultJpaDialectThis implementation invokes the standard JPATransaction.beginmethod. 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:
- beginTransactionin interface- JpaDialect
- Overrides:
- beginTransactionin class- DefaultJpaDialect
- Parameters:
- entityManager- the EntityManager to begin a JPA transaction on
- definition- 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 theSavepointManagerinterface.
- Throws:
- PersistenceException- if thrown by JPA methods
- SQLException- if thrown by JDBC methods
- TransactionException- in case of invalid arguments
- See Also:
 
- 
getJdbcConnectionpublic ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) throws PersistenceException, SQLException Description copied from class:DefaultJpaDialectThis implementation always returnsnull, indicating that no JDBC Connection can be provided.- Specified by:
- getJdbcConnectionin interface- JpaDialect
- Overrides:
- getJdbcConnectionin class- DefaultJpaDialect
- Parameters:
- entityManager- the current JPA EntityManager
- readOnly- whether the Connection is only needed for read-only purposes
- Returns:
- a handle for the Connection, to be passed into releaseJdbcConnection, ornullif no JDBC Connection can be retrieved
- Throws:
- PersistenceException- if thrown by JPA methods
- SQLException- if thrown by JDBC methods
- See Also:
 
 
-