• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

New blog: Four solutions to the LazyInitializationException

 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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. [=
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic