-->
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.  [ 2 posts ] 
Author Message
 Post subject: is it possible to load all objects in 1 query?
PostPosted: Thu Nov 15, 2007 4:25 pm 
Newbie

Joined: Thu Nov 15, 2007 9:52 am
Posts: 8
I understand the lazy-attribute,
but does hibernate fullfill the following desire on a kind of a fast bulkLoad?

The datastructure is the same as you know it from folders (and files) for example in the windows-explorer. So a folder can contain other folders (sub-folders).

- In our example folder A contains the 2 folders B and C.
- And folder B contains 3 further folders D,E and F

now there are 3 ways to load the data:
1) with lazy=true, only the folder A is loaded and the others will be loaded on demand
2) with lazy=false, all folders get loaded, BUT
- in one query hibernate determines the child-folders of A and gets B and C
- then for every child-folder a new query is used to get their child-folders

3) but the most efficient way would be just 1 single query with a result as the following:

folder, parentFolder
A, -
B, A
C, A
D, B
E, B
F, B

Now hibernate could parse this result in order to obtain the objects.

The advantage of this way is, that you need only 1 database query.


I am pretty new to hibernate. So does anyone know if there is a solution in hibernate?

I would be grateful for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 19, 2007 2:23 pm 
Newbie

Joined: Fri Mar 30, 2007 5:23 pm
Posts: 16
Location: New York, NY
Check out here:

http://www.hibernate.org/hib_docs/v3/reference/en/html/collections.html#collections-mapping

Setting the fetch="join" property should do what you are looking to do.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.