aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes What are the FetchType Lazy and Eager? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "What are the FetchType Lazy and Eager?" Watch "What are the FetchType Lazy and Eager?" New topic
Author

What are the FetchType Lazy and Eager?

woo hwang
Greenhorn

Joined: Dec 13, 2006
Posts: 23
I doo not understand the meaning of LAZY and EAGER exactly.
I have a problem to deploy 2 entities bean with one to many relaionship.
On the one side, default vaule of fetchtype is lazy.
And i have a problem with this message on JBOSS 4.2.1
"org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: ejb3.Member.spreadsh
eets, no session or session was closed"

If i change the fatchtype to eager on the one side.. another problem is happened
javax.persistence.PersistenceException: org.hibernate.HibernateException: cannot simultaneously fetch multiple bags

|A| 1 ..* |B| 1..* |C|

how should i fix this? and what is exact meaning of fetch?
cheers
Fernando Ocampo
Greenhorn

Joined: Sep 03, 2007
Posts: 1
For future references with the problem "cannot simultaneously fetch multiple bags" it seems like a hibernate bug. Check these links:

http://lists.jboss.org/pipermail/hibernate-issues/2006-August/000259.html
http://www.jroller.com/eyallupu/entry/hibernate_exception_simultaneously_fetch_multiple

Regards,
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: What are the FetchType Lazy and Eager?
 
Similar Threads
How lazy loading is working in JPA
hibernate left join fetch question
@OneToMany problem with complex PK
Questions about LAZY and EAGER loading (JPA 1.0)
problem with ejb3 fetchtype on JBoss4.2.1