aspose file tools*
The moose likes Spring and the fly likes @Transaction annotation in dao or service layer ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "@Transaction annotation in dao or service layer ?" Watch "@Transaction annotation in dao or service layer ?" New topic
Author

@Transaction annotation in dao or service layer ?

everson santos
Ranch Hand

Joined: Jul 11, 2009
Posts: 50


where is the best approach to put @Transaction annotation ? dao or service layer ?

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Depends.

Personally, I make my services transactional, my DAOs not--that way I don't need to nest transactions inside a service if I use multiple DAO calls. Of course, I also make my services implement the same interface my DAOs do, which some people find very annoying and redundant :)
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Services and only when necessary.



This is a total waste of a transaction since no other db writes are being made.


GenRocket - Experts at Building Test Data
 
 
subject: @Transaction annotation in dao or service layer ?