Two Laptop Bag*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "LazyInitializationException Help please" Watch "LazyInitializationException Help please" New topic
Author

LazyInitializationException Help please

Milan Djukic
Greenhorn

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: 1371
change lazy to eager fetching strategy.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1371
Make sure Hibernate session is used after session is closed
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: LazyInitializationException Help please
 
Similar Threads
Outer join between 3 entities in HQL
what us mean mappedBy="item" ?
IllegalArgumentException: cannot remove/save a detached entity
mappedBy reference an unknown target entity property:
Edit primary key, if it's a foreign key