org.springframework.orm.jpa.JpaDialect implementation for Hibernate.
Compatible with Hibernate ORM 5.5/5.6 as well as 6.0/6.1/6.2/6.3.
HibernateJpaVendorAdapter, org.hibernate.Session#setHibernateFlushMode , org.hibernate.Transaction#setTimeout
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private SQLExceptionTranslator | |
| pack-priv boolean | |
| private SQLExceptionTranslator |
| 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 void | cleanupTransaction(Object
arbitrary object that holds transaction data, if any
(as returned by beginTransaction or prepareTransaction) transactionData)Overrides org. Implements org. beginTransaction
implementation does not require any cleanup.
|
| protected DataAccessException | Returns: the corresponding DataAccessException instancethe HibernateException that occurred ex)Convert the given HibernateException to an appropriate exception
from the |
| protected Object | |
| 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.
|
| protected SessionImplementor | getSession(EntityManager entityManager)
Deprecated
as a consequence of
SessionImplementor being deprecated.
|
| protected FlushMode | prepareFlushMode(Session session, boolean readOnly)
Deprecated
as a consequence of
Session being deprecated.
|
| public Object | prepareTransaction(EntityManager
the EntityManager to begin a JPA transaction on entityManager, boolean whether the transaction is supposed to be read-only readOnly, String the name of the transaction (if any) name)Overrides org. Implements org. |
| public void | setJdbcExceptionTranslator(SQLExceptionTranslator
the exceptionTranslator)SQLExceptionTranslator to delegate to, or
null for none. By default, a SQLExceptionSubclassTranslator will
be used for org. translation as of 6.1;
this can be reverted to pre-6.1 behavior through setting null here.Set the JDBC exception translator for Hibernate exception translation purposes. |
| public void | setPrepareConnection(boolean prepareConnection)
Set whether to prepare the underlying JDBC Connection of a transactional Hibernate Session, that is, whether to apply a transaction-specific isolation level and/or the transaction's read-only flag to the underlying JDBC Connection. |
| public DataAccessException | translateExceptionIfPossible(RuntimeException
a RuntimeException to translate ex)Overrides org. Implements org. |
| jdbcExceptionTranslator | back to summary |
|---|---|
| private SQLExceptionTranslator jdbcExceptionTranslator
| |
| prepareConnection | back to summary |
|---|---|
| pack-priv boolean prepareConnection | |
| transactionExceptionTranslator | back to summary |
|---|---|
| private SQLExceptionTranslator transactionExceptionTranslator
| |
| HibernateJpaDialect | back to summary |
|---|---|
| public HibernateJpaDialect() | |
| 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 (
| |
| cleanupTransaction | back to summary |
|---|---|
| public void cleanupTransaction(Object transactionData) Overrides org. Implements org. Doc from org. This implementation does nothing, since the default
| |
| convertHibernateAccessException | back to summary |
|---|---|
| protected DataAccessException convertHibernateAccessException(HibernateException ex) Convert the given HibernateException to an appropriate exception
from the
| |
| getIdentifier | back to summary |
|---|---|
protected Object getIdentifier(HibernateException hibEx)
| |
| 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
| |
| getSession | back to summary |
|---|---|
| protected SessionImplementor getSession(EntityManager entityManager)
Deprecated as a consequence of | |
| prepareFlushMode | back to summary |
|---|---|
| protected FlushMode prepareFlushMode(Session session, boolean readOnly) throws PersistenceException
Deprecated as a consequence of
| |
| prepareTransaction | back to summary |
|---|---|
| public Object prepareTransaction(EntityManager entityManager, boolean readOnly, String name) throws PersistenceException Overrides org. Implements org. Doc from org. Prepare a JPA transaction, applying the specified semantics. Called by EntityManagerFactoryUtils when enlisting an EntityManager in a JTA transaction or a locally joined transaction (e.g. after upgrading an unsynchronized EntityManager to a synchronized one). An implementation can apply the read-only flag as flush mode. In that case,
a transaction data object can be returned that holds the previous flush mode
(and possibly other data), to be reset in Implementations can also use the Spring transaction name to optimize for specific data access use cases (effectively using the current transaction name as use case identifier).
| |
| setJdbcExceptionTranslator | back to summary |
|---|---|
| public void setJdbcExceptionTranslator(SQLExceptionTranslator exceptionTranslator) Set the JDBC exception translator for Hibernate exception translation purposes. Applied to any detected As of 6.1, also applied to
| |
| setPrepareConnection | back to summary |
|---|---|
| public void setPrepareConnection(boolean prepareConnection) Set whether to prepare the underlying JDBC Connection of a transactional Hibernate Session, that is, whether to apply a transaction-specific isolation level and/or the transaction's read-only flag to the underlying JDBC Connection. Default is "true". If you turn this flag off, JPA transaction management
will not support per-transaction isolation levels anymore. It will not call
Note The default behavior in terms of read-only handling changed in Spring 4.1, propagating the read-only status to the JDBC Connection now, analogous to other Spring transaction managers. This may have the effect that you're running into read-only enforcement now where previously write access has accidentally been tolerated: Please revise your transaction declarations accordingly, removing invalid read-only markers if necessary.
| |
| translateExceptionIfPossible | back to summary |
|---|---|
| public DataAccessException translateExceptionIfPossible(RuntimeException ex) Overrides org. Implements org. Doc from org. This implementation delegates to EntityManagerFactoryUtils.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final SessionImplementor | session
Deprecated
as a consequence of
SessionImplementor being deprecated.
|
| Access | Constructor and Description |
|---|---|
| public | HibernateConnectionHandle(SessionImplementor session)
Deprecated
as a consequence of
SessionImplementor being deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
| public Connection | getConnection()
Implements org. |
| session | back to summary |
|---|---|
| private final SessionImplementor session
Deprecated as a consequence of | |
| HibernateConnectionHandle | back to summary |
|---|---|
| public HibernateConnectionHandle(SessionImplementor session)
Deprecated as a consequence of | |
| getConnection | back to summary |
|---|---|
| public Connection getConnection() Implements org. Doc from org. Fetch the JDBC Connection that this handle refers to.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final FlushMode | |
| private final Integer | |
| private final boolean | |
| private final SessionImplementor | session
Deprecated
as a consequence of
SessionImplementor being deprecated.
|
| Access | Constructor and Description |
|---|---|
| public | SessionTransactionData(SessionImplementor session, FlushMode previousFlushMode, boolean connectionPrepared, Integer previousIsolationLevel, boolean readOnly)
Deprecated
as a consequence of
SessionImplementor being deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
| public void |
| needsConnectionReset | back to summary |
|---|---|
| private final boolean needsConnectionReset | |
| previousFlushMode | back to summary |
|---|---|
| private final FlushMode previousFlushMode
| |
| previousIsolationLevel | back to summary |
|---|---|
| private final Integer previousIsolationLevel
| |
| readOnly | back to summary |
|---|---|
| private final boolean readOnly | |
| session | back to summary |
|---|---|
| private final SessionImplementor session
Deprecated as a consequence of | |
| SessionTransactionData | back to summary |
|---|---|
| public SessionTransactionData(SessionImplementor session, FlushMode previousFlushMode, boolean connectionPrepared, Integer previousIsolationLevel, boolean readOnly)
Deprecated as a consequence of | |
| resetSessionState | back to summary |
|---|---|
| public void resetSessionState() | |