Ralph
Ralph

Reputation: 120791

How to do Spring Persistence Exception Translation with AspectJ

I am using Spring 3.0 with AspectJ and like use AspectJ more than AOP Proxies. That seams to work for almost every concern, but not for the Persistence Exception Translation. - My Question is how to use AspectJ for Persistence Exception Translation instead of Spring JDK AOP Proxies?

The relevant parts of my configuration are:

 <context:spring-configured/>
 ...
 <context:component-scan />
 ....
 <tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />   

Upvotes: 2

Views: 637

Answers (1)

Sean Patrick Floyd
Sean Patrick Floyd

Reputation: 298898

That should work out of the box if you compile against spring-aspects.jar. See org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect for reference. Perhaps its pointcuts don't cover your scenario, in that case you need to extend the aspect with your own pointcuts. Here are the standard pointcuts included:

pointcut entityManagerCall(): call(* EntityManager.*(..))
    || call(* EntityManagerFactory.*(..))
    || call(* EntityTransaction.*(..))
    || call(* Query.*(..));

Upvotes: 1

Related Questions