Ryan Fung
Ryan Fung

Reputation: 2217

Should there be a transactional class when using Spring @Transactional Annotation

I understand that @Transactional belongs to the Service layer, however is it good practices to make a class dedicated specifically for @Transactional operations? The purpose of this is to control/call multiple DAOs to help complete a task and return values to the service class.

Is there any advantage of doing so? Or should I just simply do everything inside my service class instead?

Upvotes: 0

Views: 63

Answers (1)

Marcelo Keiti
Marcelo Keiti

Reputation: 1240

Attempt to focus on service purpose. It will be your guideline to decide where each rule should be. If perhaps you must compose multiple services into one transaction, then propagate the transaction. You don`t need to create another class just to group multiple calls to DAOs.

Upvotes: 1

Related Questions