File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes is LAZY loading  guaranteed? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "is LAZY loading  guaranteed?" Watch "is LAZY loading  guaranteed?" New topic
Author

is LAZY loading guaranteed?

Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 201
Hello to all,


We have in our application the list of the documents(pdf,doc,xls) for the users to see. Also the use can upload the documents and search the documents. Now for the documents contents field I used LAZY loading so that when the list of the documents is presented to the user the contents of the documents should not be fetched. ONly when the documents link is clicked the contents be fetched.

But while navigation between different pages of documents I do not see considerable increase in performance of the application. It slows down when say in the upcoming list of the documents contents large documents.

How do I know that for a particular document or for all the documents lazy loading is performed. I mean how do I know tha contents are not loaded for the document.


I have read somewhere that LAZY loading is not guaranteed. I am using eclipselink.
Thanks and Regard,
Girish
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
With EclipseLink JPA you can enable SQL logging by setting the persistence.xml property,

"eclipselink.logging.level"="FINE"

This will give you a better idea of what is occurring.

In EclipseLink LAZY for OneToMany of ManyToMany is always supported. LAZY for OneToOne or ManyToOne requires that you use the EclipseLink agent is JSE (-javaagent:eclipselink.jar), or occurs automatically in JEE (provided the JEE server correctly supports EJB3). You can also use static weaving using the ant task provided by EclipseLink.

Note that EclipseLink enables caching by default, so if your object is already in the cache, you will not see any database access.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
Consider Paul's rocket mass heater.
 
subject: is LAZY loading guaranteed?