Announcement Announcement Module
Collapse
No announcement yet.
pointcut on entityManager Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • pointcut on entityManager

    Hello,

    I am playing with spring 2 aop features, I try to intercept call to the 'persist' method of entityManager in order to do something with the instance candidate for persistance. Since I do not know which implementation of javax.persistence.EntityManager I use in my code I cannot declare properly the pointcut expression. When I display this.entityManager.getClass().getName(), I just get the proxy.

    I use hibernate so I tried

    pointcut="execution(* org.hibernate.ejb.AbstractEntityManagerImpl.persis t(..)) and args(entity)" arg-names="entity"

    but with no success. The objects are correctly persisted but the aspect is not called. The same aspect works correctly when the pointcut expression concerns one of my classes.

    In the same time I manage to work with several other aspects (with / without parameters, before/after/...) but the poincut expression always targets a class of my application.

    Thanks for your opinion, and sorry if my question seems a bit naive (I am pretty new to aop in the spring 2.0 fashion). By the way, this question may be more related to hibernate than spring.

    Gengis

  • #2
    The aspect declared in this manner will apply only to the bean declared in your application context. I suspect that you don't have a bean for entity manager (and you probably don't want to have one due to other design considerations).

    A solution in such cases is to use the AspectJ weaver (which can apply to beans and non-beans equally well).

    -Ramnivas

    Comment


    • #3
      Thanks ramnivas for your answer,

      I use aspectj annotations with no problem but I did not manage to 'intercept' anything related to javax.persistence.EntityManager, even with joinpoints like this(javax.persistence.EntityManager) or target(javax.persistence.EntityManager)

      In your last post you mention the 'AspectJ weaver', do you have in mind some aspectj features not covered by spring aop ?

      Thanks, and congratulation for spring 2.0 release

      Comment


      • #4
        Originally posted by Gengis View Post
        Thanks ramnivas for your answer,

        I use aspectj annotations with no problem but I did not manage to 'intercept' anything related to javax.persistence.EntityManager, even with joinpoints like this(javax.persistence.EntityManager) or target(javax.persistence.EntityManager)

        In your last post you mention the 'AspectJ weaver', do you have in mind some aspectj features not covered by spring aop ?

        Thanks, and congratulation for spring 2.0 release
        Have you managed to find a solution to your problem? If so please share it. I am very interested.

        Comment


        • #5
          Use full-blown AspectJ, either ctw or ltw, to advise non-Spring beans. Just read the framework reference guide it's all clearly specified.

          Comment

          Working...
          X