• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Implementing Lazy loading.

 
pawan chopra
Ranch Hand
Posts: 417
jQuery Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I want to know that how lazy loading has been implemented in Hibernate and how does it work. What kind of patterns/algorithms I need to know if I want to implement lazy loading in my own application.

 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate uses proxies for that.

Excerpt from Java Persistence with Hibernate

Proxies are placeholders that are generated at runtime. Whenever Hibernate returns an instance of an entity class, it checks whether it can return a proxy instead and avoid a database hit. A proxy is a placeholder that trigger the loading ot the real object when it's accessed for the first time.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All one to many and many to many relationships default to lazy initializations. One to one associations default to eagar. So, by default, most of your associtions will be using lazy loading.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic