I am trying to handle unique key constraint violations in Spring + JPA + Hibernate.
I am using PersistenceExceptionTranslationPostProcessor to DataAccessException PersistenceException into a DataAccessException . When there is a unique key constraint violation, I expect a DuplicateKeyException or a DataIntegrityViolationException , but all I get is a JpaSystemException that wraps a PersistenceException .
Shouldn't the DataAccessException hierarchy be used so that it is small enough to not look for a provider specific error code?
How do I spring DataAccessException PersistenceException into a more specific DataAccessException ?
EDIT: I noticed that this.jpaDialect in DataAccessUtils.translateIfNecessary () is NULL. Is there some kind of setup that I need to configure to set this.jpaDialect to HibernateJpaDialect?
Thanks!
java spring jpa
Tom tucker
source share