Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@Transaction annotation in dao or service layer ?

 
everson santos
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Services and only when necessary.



This is a total waste of a transaction since no other db writes are being made.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic