spring - Where should "@Transactional" be place Service Layer or DAO -


firstly possible asking has been asked , answered before not search result . okay (or far:) ) define transactional annotations on service layer typical spring hibernate crud usually

controller->manager->dao->orm .

i have situation need choose between domain model based on client site . client using domain model other client site give me web service , not using our domain model .

which layer should replacing . believe has dao getting me data web service , sending back.i.e 2 separately written dao layers , plugged in based on scenario .

i have realized have been doing tight coupling (if there such thing or not having loose coupling) when put @transactional in service layer . many brains can not wrong or (i doubt it).

so question "where should "@transactional" place service layer or dao ?" , service layer downwards should replacing .

ideally, service layer(manager) represents business logic , hence should annotated @transactional.

service layer may call different dao perform db operations. lets assume situations have 3 dao operations in service method. if 1st dao operation failed, other 2 may still passed , end inconsistent db state. annotating service layer can save such situations.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -