类 EclipseLinkJpaDialect
- java.lang.Object
- org.springframework.orm.jpa.DefaultJpaDialect
- org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect
- 所有已实现的接口:
Serializable
,PersistenceExceptionTranslator
,JpaDialect
public class EclipseLinkJpaDialect extends DefaultJpaDialect
JpaDialect
implementation for Eclipse Persistence Services (EclipseLink). Developed and tested against EclipseLink 2.7; backwards-compatible with EclipseLink 2.5 and 2.6 at runtime.By default, this class acquires an early EclipseLink transaction with an early JDBC Connection for non-read-only transactions. This allows for mixing JDBC and JPA/EclipseLink 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.- 从以下版本开始:
- 2.5.2
- 作者:
- Juergen Hoeller
- 另请参阅:
setLazyDatabaseTransaction(boolean)
,LazyConnectionDataSourceProxy
, 序列化表格
构造器概要
构造器 构造器 说明 EclipseLinkJpaDialect()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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.void
setLazyDatabaseTransaction(boolean lazyDatabaseTransaction)
Set whether to lazily start a database resource transaction within a Spring-managed EclipseLink transaction.从类继承的方法 org.springframework.orm.jpa.DefaultJpaDialect
cleanupTransaction, prepareTransaction, releaseJdbcConnection, translateExceptionIfPossible
构造器详细资料
EclipseLinkJpaDialect
public EclipseLinkJpaDialect()
方法详细资料
setLazyDatabaseTransaction
public 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.
- 另请参阅:
UnitOfWork.beginEarlyTransaction()
beginTransaction
@Nullable public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException
从类复制的说明: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.- 指定者:
beginTransaction
在接口中JpaDialect
- 覆盖:
beginTransaction
在类中DefaultJpaDialect
- 参数:
entityManager
- the EntityManager to begin a JPA transaction ondefinition
- the Spring transaction definition that defines semantics- 返回:
- an arbitrary object that holds transaction data, if any (to be passed into
JpaDialect.cleanupTransaction(java.lang.Object)
). May implement theSavepointManager
interface. - 抛出:
PersistenceException
- if thrown by JPA methodsSQLException
- if thrown by JDBC methodsTransactionException
- in case of invalid arguments- 另请参阅:
EntityTransaction.begin()
,InvalidIsolationLevelException
,DefaultJpaDialect.cleanupTransaction(java.lang.Object)
getJdbcConnection
public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) throws PersistenceException, SQLException
从类复制的说明:DefaultJpaDialect
This implementation always returnsnull
, indicating that no JDBC Connection can be provided.- 指定者:
getJdbcConnection
在接口中JpaDialect
- 覆盖:
getJdbcConnection
在类中DefaultJpaDialect
- 参数:
entityManager
- the current JPA EntityManagerreadOnly
- whether the Connection is only needed for read-only purposes- 返回:
- a handle for the Connection, to be passed into
releaseJdbcConnection
, ornull
if no JDBC Connection can be retrieved - 抛出:
PersistenceException
- if thrown by JPA methodsSQLException
- if thrown by JDBC methods- 另请参阅:
JpaDialect.releaseJdbcConnection(org.springframework.jdbc.datasource.ConnectionHandle, javax.persistence.EntityManager)
,ConnectionHandle.getConnection()
,SimpleConnectionHandle
,JpaTransactionManager.setDataSource(javax.sql.DataSource)