Vasil
Vasil

Reputation: 38116

Spring JPA Exception Translation

I have configured my application context as stated in the spring documentation to enable Exception Translation from jpa exceptions to spring DataAccessException. Should I also provide the implementation of PersistenceExceptionTranslator? If so, can anyone give me an example of how this is done?

Upvotes: 2

Views: 1905

Answers (2)

Dhruv
Dhruv

Reputation: 10693

You can enable exception translation as well as repository scan by using following xml configuration

<jpa:repositories base-package="com.nagarro.ncpp.backend.repository" />

Upvotes: 0

Ga&#235;l Marziou
Ga&#235;l Marziou

Reputation: 16284

I do it only by putting the @Repository annotation on my DAO or Manager class that uses the EntityManager. Make sure that you enabled component scanning:

<context:component-scan base-package="org.example"/>

Upvotes: 1

Related Questions