Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question regarding Hibernate Lazy Loading

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

In one of the site i read that :

If you try to access an POJO that was not loaded with a Parent POJO in which the user'll get aLazyInitializationException.

and in another site it is

If you try to access an POJO that was not loaded with a Parent POJO the Hibernate Framework will then Load them actually from the DataBase

will you please tell me what is correct actually ??
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Neither really; both are potentially meaningless. Can you link to the sites? The quotes either look wrong or look like there may some missing detail.
 
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
If the Hibernate session is open, when you load an object, when associated objects are loaded, Hibernate will pull them from the database. If the Session is closed, you will get a Lazy exception if the associated object had not been previously loaded.

-Cameron McKenzie
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Camer on Wallace McKenzie wrote:If the Hibernate session is open, when you load an object, when associated objects are loaded, Hibernate will pull them from the database. If the Session is closed, you will get a Lazy exception if the associated object had not been previously loaded.
-Cameron McKenzie


Cameron , Have you forgotten to use the word Not here " when associated objects are loaded"


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic