• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Q 4 C. Bauer & G. King (6): "association fetching" and fetching strategy

 
blacksmith
Posts: 979
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear authors,

In the thread you mention association fetching, this means, I guess, that
Hibernate has to have an overview of all relations that compose
an object we would like to manipulate. How is the data retrieved,
table by table or does Hibernate optimize it's fetching?

Cheers,

Gian Franco Casula

[ August 31, 2004: Message edited by: Gian Franco Casula ]
[ August 31, 2004: Message edited by: Gian Franco Casula ]
 
author
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, you optimize the fetching strategy, by specifying, in mapping documents, and/or queries, whether you want an association fetched by a lazy sequential select when it is accessed, or by an outer join. In addition you can enable or disable "batch" fetching.
 
author
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are many ways to optimize association fetching, depending on the business case and the amount of data required:

1. Enable the second-level cache and hope that associated instances will mostly be found in the cache. There are situations when a cache can't (and shouldn't) be used, so you can tune this on a per-class and per-association basis.

2. Lazy load and Eager load associated entities. The first means that an associated entity is only loaded when access for the first time, the latter that a "prefetch" is executed. An eager fetch query tries to retrieve as much data as possible (or sensible) in a single query. There are several options how both strategies can be used as default (for graph navigation) and at runtime in HQL/Criteria queries.

3. Optimizations using batch fetching (not to be confused with JDBC batch operations) for "similar" collections and entities.

4. Some more minor optimization techniques.
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does "Lazy load" mean ???

 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I should be use Lazy Fetching ?

When I should be use "batch" fetching ?
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lazy load=


There are many ways to optimize association fetching, depending on the business case and the amount of data required:

2. Lazy load and Eager load associated entities. The first means that an associated entity is only loaded when access for the first time, [...]

 
You've gotta fight it! Don't give in! Read this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic