Reputation:
What are the differences?:
@Transactional
@Transactional
Thanks.
Upvotes: 2
Views: 908
Reputation: 136082
The only difference is that @Transactional is an inherited annotation (at least if we are talking about Spring) so @Transactional on a class definition will be inherited by subclasses while @Transactional on methods will not be inherited by overriding methods
Upvotes: 2
Reputation: 20073
Marking @Transactional
on all methods is the same as making the class @Transactional
.
However, say you only had 3 out of 6 methods in your class that needed to be marked transactional you should only mark those three.
Transactional Annotations should be placed around all operations that are inseparable so you also gain abilities to do things like rollback if required within one transaction.
Upvotes: 2