Hi,

I have an EJB3 entity that contains a collection of other entities.  The 
collection is both very rarely used and extremely large so I'd really rather 
not eagerly load it (in fact I can't, it makes the site slow to a crawl).  The 
problem is that I don't know how to get around the LazyInitializationException 
when you specify the collection as lazy.

I tried creating a method in my EBJ3 BL layer that did a 
entityManager.refresh(entity) and then called the entity.getCollection method, 
but that doesn't help.

I've googled all over and searched here, but I can't figure out how to 
successfully load a lazy collection in EJB3.  Removing the relationship from 
the entities would work, but that seems like it should be unnecessary.  This is 
the error I want to avoid:


  | Caused by: org.hibernate.LazyInitializationException: failed to lazily 
initialize a collection of role: com.ati.raa.entities.TdmSites.tdmAlerts, no 
session or session was closed
  | 

And the snippit:

  | @OneToMany(mappedBy = "tdmSite", fetch = FetchType.LAZY, cascade = 
CascadeType.ALL)
  |     private List<TdmAlerts> tdmAlerts;
  | 

This has got to be simple and I'm just missing something.  Can anyone help me 
out?

Thanks,
Mike

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3978604#3978604

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3978604
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to