java - Lazy loading in Hibernate -


My Java Web application uses Hibernate to ORM In some of my objects, I use lazy loading until then To get it until I need it. The problem is that I load the initial object in a session, and after that the session is destroyed when I try to resolve the lazy-loaded collection in my object later, then the following error Receives:

org.hibernate.LazyInitializationException: Failed to start a collection of role: common. Model.impl .User.groups, no session or session closed

I tried to add a new session with the archive and then tried to solve it, but it was a Only gives results.

Does anyone know how to solve lazy collection after the original session is over?

Thank you ...

- Steve

three Option:

  1. call Hibernate.in initialize (..) whenever your archive will be disconnected from the current session

  2. Announce as the collection FetchType.EAGER

  3. .

    merge (..) your user object back in new session


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -