Meaningless Drivel is fun!
The moose likes Object Relational Mapping and the fly likes LazyInitializationException Help please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "LazyInitializationException Help please" Watch "LazyInitializationException Help please" New topic

LazyInitializationException Help please

Milan Djukic

Joined: Feb 14, 2011
Posts: 27
Hi all.

Please help me, this is killing me

I have two classes A and B.

And when i call find method of class EntityManager find(A.class,id) i get a org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ......

How can i solve this, this is really killing me

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1428
change lazy to eager fetching strategy.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1428
Make sure Hibernate session is used after session is closed
It is sorta covered in the JavaRanch Style Guide.
subject: LazyInitializationException Help please
It's not a secret anymore!