• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Lazy Initialization Exception with JSF 2 and EJB 3

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm getting a Lazy exception in this scenario:

I have a ManagedBean -> EJB -> DAO.

The method in EJB calls a merge to load the collection and it works perfect. If I inspect the object in a debug mode, i can see the List loaded.

The problem is, when the EJB returns the object to my MB, I cant see the list loaded and i get a LazyInitializationException in my jsg page.

Why the list is loaded in EJB but when return to my MB the list is not loaded anymore ?

Regards,

Robert Siqueira

 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once the ejb method ends the container will also end the associated transaction. Thus making all the entities detached. Then when you try to use variables of the entities which aren't loaded it will throw an LazyInitializationException.
 
No. No. No. No. Changed my mind. Wanna come down. To see this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic