Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is LAZY loading guaranteed?

 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic