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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -