java - Lazy loading working in non-transactional class/method in Hibernate -
i working in spring-hibernate
application. flow usual: controller --> service --> dao
.
i have annotated service layer class @transactional
, thereby marking every method transactional in class.in service class, made dao
call domain object , converting dto/vo
object passed controller.for converting domain object dto
, have written custom static class(class having static methods) objectmapper
conversion.
now, domain object has child object(one many
) lazily loaded. so, when in objectmapper
, access child getter method, database call issued, working fine. don't understand since objectmapper
not transactional
, expecting exception thrown session closed
while making database call fetch child object database.i using getcurrentsession
of session factory
in dao
.
can please explain me behavior?
i suppose either call objectmapper transactional service method (you should) or if not, maybe enabled "hibernate.enable_lazy_load_no_trans" keeps hibernate session open
Comments
Post a Comment