spring-framework / org.springframework.orm.jpa / DefaultJpaDialect

DefaultJpaDialect

open class DefaultJpaDialect : JpaDialect, Serializable

Default implementation of the JpaDialect interface. Used as default dialect by JpaTransactionManager.

Simply begins a standard JPA transaction in #beginTransaction and performs standard exception translation through EntityManagerFactoryUtils.

NOTE: Spring's JPA support requires JPA 2.1 or higher, as of Spring 5.0.

Author
Juergen Hoeller

Since
2.0

See Also
JpaTransactionManager#setJpaDialect

Constructors

<init>

DefaultJpaDialect()

Default implementation of the JpaDialect interface. Used as default dialect by JpaTransactionManager.

Simply begins a standard JPA transaction in #beginTransaction and performs standard exception translation through EntityManagerFactoryUtils.

NOTE: Spring's JPA support requires JPA 2.1 or higher, as of Spring 5.0.

Functions

beginTransaction

open fun beginTransaction(entityManager: EntityManager, definition: TransactionDefinition): Any

This implementation invokes the standard JPA Transaction.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.

cleanupTransaction

open fun cleanupTransaction(transactionData: Any): Unit

This implementation does nothing, since the default beginTransaction implementation does not require any cleanup.

getJdbcConnection

open fun getJdbcConnection(entityManager: EntityManager, readOnly: Boolean): ConnectionHandle

This implementation always returns null, indicating that no JDBC Connection can be provided.

prepareTransaction

open fun prepareTransaction(entityManager: EntityManager, readOnly: Boolean, name: String): Any

releaseJdbcConnection

open fun releaseJdbcConnection(conHandle: ConnectionHandle, em: EntityManager): Unit

This implementation does nothing, assuming that the Connection will implicitly be closed with the EntityManager.

If the JPA implementation returns a Connection handle that it expects the application to close after use, the dialect implementation needs to invoke Connection.close() (or some other method with similar effect) here.

translateExceptionIfPossible

open fun translateExceptionIfPossible(ex: RuntimeException): DataAccessException

This implementation delegates to EntityManagerFactoryUtils.

Inheritors

HibernateJpaDialect

open class HibernateJpaDialect : DefaultJpaDialect

org.springframework.orm.jpa.JpaDialect implementation for Hibernate EntityManager. Developed against Hibernate 5.0/5.1/5.2.