views:

40

answers:

1

Firstly it is possible that I am asking something that has been asked and answered before but I could not get a search result back . Okay generally (or always so far:) ) We define transactional annotations on service layer typical spring hibernate crud is usually

Controller->Manager->Dao->Orm .

I now have a situation where I need to choose between the domain model based on client site . Say client A is using my domain model all is good but then an other client site would give me a web service and not be using our domain model .

Which layer should I be replacing . I believe it has to be Dao which will be getting me data from web service and sending it back.i.e two separately written Dao layers and plugged in based on scenario .

I have now realized that we have been doing tight coupling (if there is such a thing or say not having loose coupling) when we put @Transactional in Service layer . So many brains can not be wrong or are they (I doubt it).

So question is "Where should "@Transactional" be place Service Layer or DAO ?" and is it service layer downwards I should be replacing .

+1  A: 

You are going to want your services to be transactional. If your DAOs are transactional, and you call different DAOs in each service, then you would have multiple txs, which is not what you want. Make the service calls transactional, and all DAO calls inside those methods will participate in the tx for the method.

hvgotcodes