aspose file tools
The moose likes Struts and the fly likes Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Hibernate" Watch "Hibernate" New topic
Author

Hibernate

Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 676

Hi All,

Can any one tell me why we use in Hibernate lazy="false" when we use many-to-one , set and other relation with table.

Please help me ASAP

Thanks,
Nishan


Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3268

From the Hibernate documentation:

"Alternatively, we could use a non-lazy collection or association, by specifying lazy="false" for the association mapping. However, it is intended that lazy initialization be used for almost all collections and associations. If you define too many non-lazy associations in your object model, Hibernate will end up needing to fetch the entire database into memory in every transaction!"

In short, you don't want to load the entire DB by accident through a chain of associations

Hope that helps!


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 676

Hi ,

Thank you Martijn Verburg

I get rough idea about why we use lazy="false"

Thanks again
Nishan.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Hibernate
 
Similar Threads
how we can call stored procedure in hibernate?
transaction in session bean
Use of Hibernate
Hibernate Connection Pooling.
Need Suggestion about Spring IoC, Hibernate Search, Hibernate Shard integration.. :D