Lazy loading in Hibernate

Posted by Steve on Stack Overflow See other posts from Stack Overflow or by Steve
Published on 2010-02-01T20:19:18Z Indexed on 2010/05/01 0:47 UTC
Read the original article Hit count: 325

Filed under:
|
|
|
|

My Java Web application uses Hibernate to perform ORM. In some of my objects, I use lazy loading to avoid getting data until I absolutely need it. The problem is that I load the initial object in a session, and then that session is destroyed. When I later attempt to resolve the lazy-loaded collections in my object I get the following error:

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: common.model.impl.User.groups, no session or session was closed

I tried associating a new session with the collection and then resolving, but this gives the same results.

Does anyone know how I can resolve the lazy collections once the original session is gone?

Thanks...

--Steve

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about lazyload