aspose file tools*
The moose likes Object Relational Mapping and the fly likes what are the disadvantage of Lazy and eager fetching?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "what are the disadvantage of Lazy and eager fetching??" Watch "what are the disadvantage of Lazy and eager fetching??" New topic
Author

what are the disadvantage of Lazy and eager fetching??

jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
what are the disadvantage of Lazy and eager fetching??
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Not to be rude, but have you read the documentation? Its pretty clear on these topics. Rather than simply repeat what that say here I recommend you go and have a read.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Well, eagar fetching can give you more data than you need and cause inefficiencies. Alternatively, lazy loading might not give you enough data, and you either get Lazy Loading Exceptions, or you have multiple trips back and forth to the database to get what you need.

Here's a little tutorial on how hibernate works. It might provide you some more information on what you're after:

How Hibernate Works

-Cameron McKenzie
jacob deiter
Ranch Hand

Joined: Apr 02, 2008
Posts: 576
NO Actually If the association is large then It will create any problem??.Actually I had a discussion,in that ,people suggest eager and lazy fetching has many advantage as well disadvantage.

I can figure out advantage but not able to find Disadvantage since I do not work on extensively

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Actually Cameron gave you the entire gist of it for you to see the advantages and disadvantages.

Basically they have the same advantages and disadvantages but opposite of each other.

Fetching should be use case driven and not mapping driven. So for me the best approach is everything is mapped as lazy loading, and now I can set the fetching strategy at query time. So when I have a use case that needs X amount of data I get X amount of data and nothing more and nothing less. If you choose lazy all the time for everything then you will be getting less than X for most of your use cases. If you eager fetch everything by default, then you will be getting more than X for most of your use cases.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what are the disadvantage of Lazy and eager fetching??