org.springframework.orm.jpa.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.
setLazyDatabaseTransaction, org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy
| Modifier and Type | Class and Description |
|---|---|
| private static class | EclipseLinkJpaDialect.EclipseLinkConnectionHandle
|
| Modifier and Type | Field and Description |
|---|---|
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Object | beginTransaction(EntityManager
the EntityManager to begin a JPA transaction on entityManager, TransactionDefinition the Spring transaction definition that defines semantics definition)Overrides org. Implements org. Transaction.begin
method.
|
| public ConnectionHandle | getJdbcConnection(EntityManager
the current JPA EntityManager entityManager, boolean whether the Connection is only needed for read-only purposes readOnly)Overrides org. Implements org. null,
indicating that no JDBC Connection can be provided.
|
| public void | setLazyDatabaseTransaction(boolean lazyDatabaseTransaction)
Set whether to lazily start a database resource transaction within a Spring-managed EclipseLink transaction. |
| lazyDatabaseTransaction | back to summary |
|---|---|
| private boolean lazyDatabaseTransaction | |
| EclipseLinkJpaDialect | back to summary |
|---|---|
| public EclipseLinkJpaDialect() | |
| beginTransaction | back to summary |
|---|---|
| public Object beginTransaction(EntityManager entityManager, TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException Overrides org. Implements org. Doc from org. This implementation invokes the standard JPA 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 (
| |
| getJdbcConnection | back to summary |
|---|---|
| public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) throws PersistenceException, SQLException Overrides org. Implements org. Doc from org. This implementation always returns
| |
| setLazyDatabaseTransaction | back to summary |
|---|---|
| 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. 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. | |
ConnectionHandle implementation that lazily fetches an
EclipseLink-provided Connection on the first getConnection call -
which may never come if no application code requests a JDBC Connection.
This is useful to defer the early transaction begin that obtaining a
JDBC Connection implies within an EclipseLink EntityManager.
| Modifier and Type | Field and Description |
|---|---|
| private Connection | |
| private final EntityManager |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Connection | getConnection()
Implements org. |
| connection | back to summary |
|---|---|
| private Connection connection
| |
| entityManager | back to summary |
|---|---|
| private final EntityManager entityManager | |
| EclipseLinkConnectionHandle | back to summary |
|---|---|
| public EclipseLinkConnectionHandle(EntityManager entityManager) | |
| getConnection | back to summary |
|---|---|
| public Connection getConnection() Implements org. Doc from org. Fetch the JDBC Connection that this handle refers to.
| |