Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

LazyInitializationException in Spring

clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, I don't know if this question belongs to ORM forum or Application framework forum, but I will post it here, and our moderators can move it.
My application uses Struts, Spring and Hibernate and I mapped the relationships as lazy with batch fetch attribute.
I'm using Spring's support for Hibernate (HibernateDaoSupport) and you know, getHibernateTemplate and Spring's declerative transaction management.
Well, my Struts action gets the specified object using Hibernate and then set that object is request scope and forwards the request to a JSP page for displaying stuffs.
As you might have realised, I got LazyInitializationException because there is no opened Hibernate Session.
One solution to this problem is to fetch the collection eagrly but I want to fetch it lazly.
Is it possible to use HibernateUtil class (from CeaverEmptor application) with Spring's support class ?
Any ideas ?
permaculture is largely about replacing oil with people. And one tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
    Bookmark Topic Watch Topic
  • New Topic