-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: (Deep) Eager loading in Hibernate
PostPosted: Wed Sep 24, 2003 3:53 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 3:14 am
Posts: 20
Location: Munich, Germany
Hi,

i'm quite new to Hibernate, and after reading Chapter 11 from the Hibernate documentation, i wonder if Hibernate also supports "deep eager loading".

I want to read a net of objects starting from root object as fast as possible.
From my experience the performance of such a reading is (as a first approximation) direct proportional to the number of SQL requests (=number of DB roundtrips).
Therefore, i would like that only one SQL select is performed per table, regardless of how the various entries in a table are connected to their parents.

Example:
Let's assume we have four entities:
    event,
    order,
    ticket and
    promotion_logo

An event has n1 order's, a order has n2 ticket's, and a ticket points to any number of promotion_logo's.

In a concrete case, an event has n1=3 orders, each order has n2=3/4/2 tickets and the various tickets point to 0..4 promotion_logo entries.

Some O/R mapper i know of optimze the reading of relationships only at "level 1", so it generates 14 SQL statements (1 to read the event, 1 to read the orders, 3 to read the tickets for each order and 9 to read the promotion_logo's for each ticket).

Obviously, you could do the same in 4 SQL select statements, one for each table.

Can i instruct Hibernate to do a "deep eager loading"?

Bye,

J


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2003 4:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
yes, of course. please refer to the Hibernate manual.


Top
 Profile  
 
 Post subject: (Deep) Eager loading in Hibernate per query
PostPosted: Wed Sep 24, 2003 5:13 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 3:14 am
Posts: 20
Location: Munich, Germany
Hi,

i think i found the deep eager loading feature (the lazy parameter in the map XML element, right?).

Unfortunately, this is not a per-query setting, so all queries have to share the lazy/eager loading settings of the object graph.

Is this right?
(I'm a newbie, so i if missed something obvious, sorry!)

Bye,

J


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2003 5:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ummm. If you want per-query deep fetching, please refer to the section of the manual which talks about queries!

eg. in HQL there is a FETCH keyword.


Top
 Profile  
 
 Post subject: thanks!
PostPosted: Wed Sep 24, 2003 5:32 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 3:14 am
Posts: 20
Location: Munich, Germany
If every product i use would have such great support ...

I read the "fetch" statement, but because my pattern matching was focused on "lazy|eager" i didn't understand it.

A "Chapter 11.2 Eager Loading" with a short description that
a) the performance for reading object graps is direct propertional to the number of DB roundtrips (=SQL selects)
b) eager loading can be done in the mapping by not using proxies (with a pointer to Chapter 5.2)
c) eager queries need to specify the "fetch join" (with a pointer to Chapter 9.3)

would be very helpful!

Bye,

J


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.