*
The moose likes Struts and the fly likes Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Hibernate" Watch "Hibernate" New topic
Author

Hibernate

Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 684

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: 3274
    
    5

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: 684

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://aspose.com/file-tools
 
subject: Hibernate
 
Similar Threads
Need Suggestion about Spring IoC, Hibernate Search, Hibernate Shard integration.. :D
transaction in session bean
how we can call stored procedure in hibernate?
Hibernate Connection Pooling.
Use of Hibernate