• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.hibernate.LazyInitializationException

 
Ramesh Bende
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We get org.hibernate.LazyInitializationException intermittently in our application in different places.
Its difficult identify the problem because it comes rarely and at different places. So is this because of the session timeout or something? Is there any configuration that we can set in hibernate.properties to avoid this problem. We certainly want lazy initialization since our DB is normalized. So turning off lazy initialization is not an option.
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This exception is encountered when you try to access an object or collection on an entity that was not initialized. You can trigger a lazy load by accessing collections or objects while still inside the transaction. However once leaving the transaction your entity becomes detached. Apparently you have certain conditions in your application that when met are allowing the entity to become detached without triggering a lazy load on objects (most likely collections) that are needed later once the transaction has ended. One way to fix this problem is to make sure that you are triggering a lazy load on any objects that you will need later before leaving the transaction.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic