【问题标题】:How to do Spring Persistence Exception Translation with AspectJ如何使用 AspectJ 进行 Spring 持久性异常翻译
【发布时间】:2011-07-22 09:53:02
【问题描述】:

我正在使用带有 AspectJ 的 Spring 3.0,并且喜欢使用 AspectJ 而不是 AOP 代理。 这似乎适用于几乎所有问题,但不适用于持久性异常翻译。 - 我的问题是如何使用 AspectJ 进行持久性异常翻译而不是 Spring JDK AOP 代理?

我的配置的相关部分是:

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

【问题讨论】:

    标签: java spring jpa aop aspectj


    【解决方案1】:

    如果您针对 spring-aspects.jar 进行编译,那应该可以立即使用。请参阅org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect 以供参考。也许它的切入点不涵盖您的场景,在这种情况下,您需要使用自己的切入点扩展方面。以下是包含的标准切入点:

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

    【讨论】:

      猜你喜欢
      • 2012-01-16
      • 2013-05-20
      • 2012-08-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-27
      • 2011-09-15
      相关资源
      最近更新 更多