Announcement Announcement Module
Collapse
No announcement yet.
Unexpected transaction behaviour Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unexpected transaction behaviour

    I've been further investigating the transaction behaviour I asked for help about yesterday and I've reached some conclusions. They aren't what I would have expected a-priori, so I'd like some conformation of what I'm seeing is indeed what is expected.

    What I'm observing is:

    Both the cases involve one transactioned method calling another. When the two methods are in different classes the defined transactional behaviour of the second, called, method is taken into account. However, when the two methods are in the same class, the transactional attribute of the second method is ignored. It appears never to be looked up by the TransactionInterceptor.

    Can anyone confirm this is expected behaviour, and if not, any suggestions about what I might be doing wrong to observe it.

    thanks,
    Jonny

  • #2
    If I understood your observation, you are talking about a general "problem" with Spring AOP implementation.
    Spring uses proxies to implement AOP which means:
    - If you call a proxied method on a bean that is obtained from applicationContext, the Advice will kicks-in
    - If method1 of your bean calls method2 on the same bean, the advice will not work since Spring AOP implementation does not intercept this call.

    To solve this, you should make method1 calls adviced method2 in place of method2.
    This thread shows how you can do it: AOP, Proxies, and method calling in same instance
    HTH
    Last edited by robyn; May 14th, 2006, 10:37 AM.

    Comment


    • #3
      Omar,

      thanks for the reply, and yes, that hits my observation right on. Thanks for pointing out the functionality of the proxy based AOP. I can now see where the transaction behaviour comes from.

      I don't think this will be a problem in my code, but it's good to know what the behaviour actually is.

      Jonny

      Originally posted by irbouho
      If I understood your observation, you are talking about a general "problem" with Spring AOP implementation.
      Spring uses proxies to implement AOP which means:
      - If you call a proxied method on a bean that is obtained from applicationContext, the Advice will kicks-in
      - If method1 of your bean calls method2 on the same bean, the advice will not work since Spring AOP implementation does not intercept this call.

      To solve this, you should make method1 calls adviced method2 in place of method2.
      This thread shows how you can do it: AOP, Proxies, and method calling in same instance
      HTH
      Last edited by robyn; May 14th, 2006, 10:38 AM.

      Comment

      Working...
      X