redfox26
redfox26

Reputation: 2070

Spring transaction annotation

I have a method aaa, it calls method bbb and ccc.

If there is a problem in bbb or ccc, I want to rollback.

I put for method aaa this annotation

@Transactional(propagation=Propagation.REQUIRED),

do I need to put the same value in term of annotation for method bbb and ccc or I can use only this?

@Transactional

Upvotes: 0

Views: 133

Answers (1)

sus007
sus007

Reputation: 295

You are just required to put @Transactional in aaa method and you don't have to put @Transactional(propagation=Propagation.REQUIRED) to bbb and ccc methods because Spring transaction will handle by itself and takes this property as a default. If you want to isolate bbb method from this transaction started by aaa then put @Transactional(propagation=Propagation.REQUIRES_NEW) on bbb method.

Upvotes: 2

Related Questions