0
votes

It is a good practice to work in controller and view of Spring MVC application with JPA detached objects?

If yes, then only gain of lazy initialization is in scope of single DAO call - am I right? Also, with lot of operations don't spreaded in multiple controllers (beacause all data-action must be executed in single dao-transactional-call) how to split DAO operations to more classes? Create specialized, related only by entity DAOs?

Is it possible to span a transaction on controller method call, not single DAO call? And would it be a bad practice?

1

1 Answers

0
votes

Transactions should be on your service layer classes, and sometimes on your daos/repositories. But definitely not on your controllers.

You have two dao calls, and you want one transaction ? That is exactly what a service class is for.