• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

fetching data :: eager Vs lazy

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic