aspose file tools*
The moose likes Blatant Advertising and the fly likes New blog: Four solutions to the LazyInitializationException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Other » Blatant Advertising
Bookmark "New blog: Four solutions to the LazyInitializationException" Watch "New blog: Four solutions to the LazyInitializationException" New topic
Author

New blog: Four solutions to the LazyInitializationException

Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Hello. I have Just created a new blog about: Four solutions to the LazyInitializationException.

In this blog you will see:
* Understanding the problem, Why does LazyInitializationException happen?
* Load collection by annotation
* Load collection by Open Session in View (Transaction in View)
* Load collection by Stateful EJB with PersistenceContextType.EXTENDED
* Load collection by Join Query
* EclipseLink and lazy collection initialization

I hope you like it. [=

[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Just a comment on your EclipseLink section,

Note that EclipseLink does not have this issue (at all), and it has nothing to do with EAGER. EclipseLink supports LAZY in JEE and JSE, for JSE you must use either dynamic weaving using an agent, or static weaving.

The reason EclipseLink does not have this issue is that when you access a LAZY relationship outside of the transaction, or after the EntityManager has been closed, EclipseLink just acquires a new connection from its connection pool to read the related objects.

The only time you will have this issue with EclipseLink is when you serialize the object, then the LAZY will be dead and you will get an error. In EclipseLink you can use JOIN FETCH, fetch groups, or load groups to resolve the issue.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Hello James,

I will answer here the same I will answer there.

I did not want to expose that behavior like a bug, or issue.

Maybe my english was not clear enough.

That is why I quoted the JPA spec. The implementation may do whatever it wants to.

The link http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#What_You_May_Need_to_Know_About_EclipseLink_JPA_Lazy_Loading shows that the EclipseLink has LAZY for JSE and JEE.

Thanks for your feedback
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: New blog: Four solutions to the LazyInitializationException
 
Similar Threads
LazyInitializationException
LazyInitializationException
LazyInitializationException
LazyInitializationException and transaction
LazyInitializationException