Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fetching data :: eager Vs lazy

 
satish bodas
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic