Meaningless Drivel is fun!*
The moose likes Object Relational Mapping and the fly likes Q 4 C. Bauer & G. King (6): Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Q 4 C. Bauer & G. King (6): "association fetching" and fetching strategy" Watch "Q 4 C. Bauer & G. King (6): "association fetching" and fetching strategy" New topic
Author

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

Gian Franco
blacksmith
Ranch Hand

Joined: Dec 16, 2003
Posts: 977
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 ]

"Eppur si muove!"
Gavin King
author
Ranch Hand

Joined: Aug 31, 2004
Posts: 76
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.


Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/193239415X/ref=jranch-20" target="_blank" rel="nofollow">Hibernate in Action</a>
Christian Bauer
author
Ranch Hand

Joined: Aug 31, 2004
Posts: 45
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.


Co-Author of <a href="http://www.manning.com/bauer" target="_blank" rel="nofollow">Hibernate in Action</a>
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
What does "Lazy load" mean ???



SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
When I should be use Lazy Fetching ?

When I should be use "batch" fetching ?
Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
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, [...]


blog - InfoQ.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Q 4 C. Bauer & G. King (6): "association fetching" and fetching strategy
 
Similar Threads
Hibernate cache and data from backend
Q about IBM 486 and others: which books are reccomended?
Q 4 C. Bauer & G. King (1): how Hibernate relates to JDBC
IDEs support Hibernate ???
Q 4 C. Bauer & G. King (2): Hibernate & formulating queries