This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Lazy Initialization Exception with JSF 2 and EJB 3

 
Robert Siqueira
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • 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

 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 1
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic