PersistenceExceptionTranslator capable of translating HibernateException
instances to Spring's DataAccessException hierarchy. As of Spring 4.3.2 and
Hibernate 5.2, it also converts standard JPA PersistenceException instances.
Extended by LocalSessionFactoryBean, so there is no need to declare this
translator in addition to a LocalSessionFactoryBean.
When configuring the container with @Configuration classes, a @Bean
of this type must be registered manually.
org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor , SessionFactoryUtils#convertHibernateAccessException(HibernateException), EntityManagerFactoryUtils#convertJpaAccessExceptionIfPossible(RuntimeException)
| Modifier and Type | Field and Description |
|---|---|
| private SQLExceptionTranslator |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected DataAccessException | Returns: a corresponding DataAccessExceptionthe HibernateException that occurred ex)Convert the given HibernateException to an appropriate exception from the
|
| public void | setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
Set the JDBC exception translator for Hibernate exception translation purposes. |
| public DataAccessException | translateExceptionIfPossible(RuntimeException
a RuntimeException to translate ex)Implements org. org. hierarchy, if possible.
|
| jdbcExceptionTranslator | back to summary |
|---|---|
| private SQLExceptionTranslator jdbcExceptionTranslator
| |
| HibernateExceptionTranslator | back to summary |
|---|---|
| public HibernateExceptionTranslator() | |
| convertHibernateAccessException | back to summary |
|---|---|
| protected DataAccessException convertHibernateAccessException(HibernateException ex) Convert the given HibernateException to an appropriate exception from the
Will automatically apply a specified SQLExceptionTranslator to a Hibernate JDBCException, otherwise rely on Hibernate's default translation.
| |
| setJdbcExceptionTranslator | back to summary |
|---|---|
| public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator) Set the JDBC exception translator for Hibernate exception translation purposes. Applied to any detected | |
| translateExceptionIfPossible | back to summary |
|---|---|
| public DataAccessException translateExceptionIfPossible(RuntimeException ex) Implements org. Doc from org. Translate the given runtime exception thrown by a persistence framework to a
corresponding exception from Spring's generic
Do not translate exceptions that are not understood by this translator: for example, if coming from another persistence framework, or resulting from user code or otherwise unrelated to persistence. Of particular importance is the correct translation to DataIntegrityViolationException, for example on constraint violation. Implementations may use Spring JDBC's sophisticated exception translation to provide further information in the event of SQLException as a root cause.
| |