Announcement Announcement Module
Collapse
No announcement yet.
Spring Transaction using annotation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Transaction using annotation

    Hi
    I am attempting to start Spring Transactions declaratively the following ways:

    //in my source file I have set my transaction manager
    <!-- from the file 'context.xml' -->
    <tx:annotation-driven transaction-manager="txManager"/>

    ..

    //source file
    Code:
    @Transactional
    public class DefaultFooService implements FooService {
    
        public void getFoo(String fooName, String barName){
           logger.info("foo method called");
           newTransaction();  
        }
    
        @Transactional(propagation=Propagation.REQUIRES_NEW)
        public void newTransaction(){
           logger.info("should have started a new transaction");
        }
    
    }
    //
    I am able to see that the transaction is started when I make a call to the getFoo() method. However, there is no new Transaction created when newTransaction() method is being invoked from getFoo() method.

    Can anyone explain why or how I can achieve to start a new transaction within the parent transaction?

    thanks
    Last edited by sonam; Dec 9th, 2010, 10:15 AM.

  • #2
    Use [ code][/code ] tags when posting that way it remains readable...

    Use the search as this question has been answered numerous times before.

    Short answer, the drawback of proxy based aop (read the aop chapter section 6.6 of the reference guide).

    Comment

    Working...
    X