In 3 tier application we have the facade, business, dao layers.
I want that the dao will return detached objects.
The transaction is open in the facade , so change in the facade or the businees layer to the objects which has been return by the dao will persist the change and i dont want changes that are not done through the dao layer.
the idea that i think on them is cloen the objects (but this is required to go over the object graph)
or set the dao transaction scope to new transaction.
avihai marchiano wrote:The facade is the service layey - stateless bean.
The question is where the transaction start - in the first time i do a db action or when i call explicity to userTransaction.begin or implicity by having transaction annotation...
OK, I got confused when you had facade and business seperate, but I haven't used EJBs in a long time, so what you have is perfect. and yes the Facade is the transaction boundary. The Facade is the interface to the outside world and represents each use case and transactions should be bound at the use case, service layer. That way if your service has to call mutliple DAOs/Repositories, they will all be within the same transaction, since you want it that way. If any one of the queries fail, then you want the whole use case to fail (in most cases), you want the whole use case to be Atomic.