1
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void a(){
    a();
    b();
}
@Transactional(propagation = Propagation.REQUIRED)
public void b(){
    //do something
}
@Transactional(propagation = Propagation.REQUIRED)
public void c(){
    //do something
}

the method b() and the method c() use same transaction? thanks.

yuansf
  • 11
  • 2
  • 1
    I recommend reading this http://stackoverflow.com/questions/1099025/spring-transactional-what-happens-in-background to get a grasp on how `@Transactional` works and what happens in this particular case. – chimmi Sep 09 '16 at 12:28

1 Answers1

1

I think your code should be corrected to prevent from recursive call as follows:

@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void a(){
    c();
    b();
}

In this case c() and b() will not be executed in a transaction, @Transactional annotation is only valid if a method is called from outside class, not within the same class.

chimmi
  • 2,054
  • 16
  • 30
hunter
  • 3,963
  • 1
  • 16
  • 19
  • Although I understand what you are saying, I think 'called from outside class' is incorrect. Manually creating an instance and calling `a()` on it meets this criteria, but it wont work for obvious reasons. – chimmi Sep 09 '16 at 12:31