Does it make sense to use PersistenceExceptionTranslationPostProcessor with Spring JdbcTemplate?

The title speaks for itself.

Is PersistenceExceptionTranslationPostProcessor used exclusively for JPA implementations, or does it make sense to use it with Spring JdbcTemplate?

And if there are two data sources, each of which has its own JPA entity manager and transaction manager, do I still need to specify only one PersistenceExceptionTranslationPostProcessor for the entire application?

+4
source share
2 answers

Automatic reward reward is incorrect

~~~ The correct answer is: ~~~

, : http://www.deroneriksson.com/tutorials/java/spring/introduction-to-the-spring-framework/component-scanning-and-repository

@Repository , Spring. , JdbcTemplate . Hibernate, Spring, Hibernate Spring. , , Hibernate DAO, @Repository, Hibernate, Spring, PersistenceExceptionTranslationPostProcessor.

: http://www.deroneriksson.com/tutorials/java/spring/introduction-to-the-spring-framework/hibernate-daos

: , JdbcTemplate

, , PersistenceExceptionTranslationPostProcessor jdbcTemplate

+1

, , Spring beans, @Repository, post bean post processor bean :

<bean id="persistenceExceptionTranslationPostProcessor"
   class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />

doc

Bean , bean, Spring @Repository , PersistenceExceptionTranslationAdvisor ( - AOP -, ).

Spring DataAccessException. Autodetects beans, PersistenceExceptionTranslator, . Spring (, LocalContainerEntityManagerFactoryBean) PersistenceExceptionTranslator . , , beans (, DAO) @Repository, - bean .

, Jdbctemplate, Jpa

doc All of Spring applicable resource factories (e.g. LocalContainerEntityManagerFactoryBean) implement the PersistenceExceptionTranslator interface out of the box, , PersistenceExceptionTranslationPostProcessor, , (HibernateExceptions, PersistenceExceptions...) DataAccessException.

+1

Source: https://habr.com/ru/post/1675272/


All Articles