Results 1 to 3 of 3

Thread: Unexpected transaction behaviour

  1. #1
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    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 at 10:37 AM.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Aug 2004
    Location
    San Francisco
    Posts
    423

    Default

    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

    Quote 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 at 10:38 AM.

Similar Threads

  1. Unit testing with JOTM and JtaTransactionManager
    By lalle in forum Architecture
    Replies: 1
    Last Post: Oct 15th, 2005, 09:05 AM
  2. Replies: 0
    Last Post: Jun 6th, 2005, 06:22 AM
  3. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM
  4. Transaction Behaviour
    By jwray in forum Data
    Replies: 2
    Last Post: Oct 20th, 2004, 03:39 PM
  5. Transaction pb Hibernate/MySQL
    By syluser in forum Data
    Replies: 2
    Last Post: Aug 28th, 2004, 02:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •