Starting new transaction within existing one in Spring bean
        Posted  
        
            by Marcus
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Marcus
        
        
        
        Published on 2010-06-14T12:00:48Z
        Indexed on 
            2010/06/14
            12:02 UTC
        
        
        Read the original article
        Hit count: 333
        
spring
|transactions
We have:
@Transactional(propagation = Propagation.REQUIRED)
public class MyClass implementes MyInterface { ...
MyInterface has a single method: go().  
When go() executes we start a new transaction which commits/rollbacks when the method is complete - this is fine.
Now let's say in go() we call a private method in MyClass that has @Transactional(propagation = Propagation.REQUIRES_NEW.  It seems that Spring "ignores" the REQUIRES_NEW annotation and does not start a new transaction.  I believe this is because Spring AOP operates on the interface level (MyInterface) and does not intercept any calls to MyClass methods.  Is this correct?
Is there any way to start a new transaction within the go() transaction? Is the only way to call another Spring managed bean that has transactions configured as REQUIRES_NEW?
© Stack Overflow or respective owner