spring-framework / org.springframework.dao.annotation / PersistenceExceptionTranslationPostProcessor / <init>

<init>

PersistenceExceptionTranslationPostProcessor()

Bean post-processor that automatically applies persistence exception translation to any bean marked with Spring's @org.springframework.stereotype.Repository annotation, adding a corresponding PersistenceExceptionTranslationAdvisor to the exposed proxy (either an existing AOP proxy or a newly generated proxy that implements all of the target's interfaces).

Translates native resource exceptions to Spring's org.springframework.dao.DataAccessException hierarchy. Autodetects beans that implement the org.springframework.dao.support.PersistenceExceptionTranslator interface, which are subsequently asked to translate candidate exceptions.

All of Spring's applicable resource factories (e.g. org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) implement the PersistenceExceptionTranslator interface out of the box. As a consequence, all that is usually needed to enable automatic exception translation is marking all affected beans (such as Repositories or DAOs) with the @Repository annotation, along with defining this post-processor as a bean in the application context.

Author
Rod Johnson

Author
Juergen Hoeller

Since
2.0

See Also
PersistenceExceptionTranslationAdvisororg.springframework.stereotype.Repositoryorg.springframework.dao.DataAccessExceptionorg.springframework.dao.support.PersistenceExceptionTranslator