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:
-
call
Hibernate.in initialize (..)
whenever your archive will be disconnected from the current session -
Announce as the collection
FetchType.EAGER
- .
merge (..)
your user object back in new session
Comments
Post a Comment