aspose file tools*
The moose likes Object Relational Mapping and the fly likes fetching data :: eager Vs lazy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "fetching data :: eager Vs lazy" Watch "fetching data :: eager Vs lazy" New topic
Author

fetching data :: eager Vs lazy

satish bodas
Ranch Hand

Joined: Jun 19, 2008
Posts: 116
Using JPA ( with underlying provider as Hibernate )
This fetch mode is defined in the association annotation itself



This means that in the client that makes use of this code is stuck
The behaviour is fixed .

Istnt that a disadvantage ?
Can I not change it dynamically based on what client wants ?

There very well could be scenarios that for a user A I only have 2-3 records as addresses and for User B I have 100 records as addresses

I want to do a eager load of data for User A and a lazy load for user B .

Thanks ,
~satish
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Which is why the default is to load lazy. So that only on use case do you say I want that eager. In creating Query objects you can then set the association to eager load. It should always be use case driven and not one default to rule them all.

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: fetching data :: eager Vs lazy