Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use of @org.springframework.transaction.annotation.Transactional outside of the DAO layer?

i have a quite classical issus : Access Lazy Collection outside of the DAO, witch lead to LazyInitializationException.

Is that a clean and reasonable solution to use @Transactional one some method of the service, outside of the DAO, who use these lazy collection ?

Thanks

like image 327
Antoine Claval Avatar asked Jan 21 '23 21:01

Antoine Claval


1 Answers

Yes it is. The one who knows which tasks must be a unit of work (a Transaction) is the service, because it is the one who "knows" the business.

like image 135
Neuquino Avatar answered Jan 23 '23 11:01

Neuquino