This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Hibernate - lazy vs. eager loading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate - lazy vs. eager loading" Watch "Hibernate - lazy vs. eager loading" New topic

Hibernate - lazy vs. eager loading

Rish Pan

Joined: Apr 15, 2005
Posts: 3
Hey all--

I'm new to this forum (and actually to JavaRanch in general)! Any best practices/etiquette advice is always welcome.

My group is using Hibernate for our current project. This is my first time using the tool and I have some questions regarding lazy vs. eager loading.

In the hbm files, there is a 'lazy' attribute which allows one to specify if a related collection should be eagerly loaded or not. There is also a 'batch-size' attribute which defaults to 1. How is this attribute used?

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
lazy=true improves performance: if some class has a bag/set, their elements are loaded only after you make an explicit call to MyObject.mySet

but hibernate site explains it here and here

i'd recommend you browse hibernate docs (they come with download): quite an excelent aid!

java amateur
wood burning stoves
subject: Hibernate - lazy vs. eager loading
It's not a secret anymore!