-->
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.  [ 6 posts ] 
Author Message
 Post subject: Recursivity and query questions
PostPosted: Wed Oct 22, 2003 9:50 am 
Newbie

Joined: Wed Oct 22, 2003 9:42 am
Posts: 2
Location: France
Hello,

I want to use Hibernate with Parent / Child relationships and I have questions about it. I can't find answer in the userguide...

When someone makes a query, only elements are retrieved and what about the relations? A 'getParent' ( or equivalent ) make a new request or the instance is yet retrieved ( with a parameter to tell the deep of recursivity: for example tow levels )?

The aim of my question is to make the equivalent of a UNIQUE sql request that retrieve a list of people with informations about parents... And what about the performance if the equivalent in Hibernate make several requests?

Thanks by advance for your help,
Thierry


Top
 Profile  
 
 Post subject: Re: Recursivity and query questions
PostPosted: Wed Oct 22, 2003 10:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hum, suchs question are answered in the reference guide, and are hard to sumarize.
The answer is 'it depends'.

I'll give you a start point.

On each collection relationship, you can add the lazy="true" parameter
if lazy=false, (and outer join capabilities = true), there will be 1 request
if lazy = true, no request on collectioned data are performed until you really access those data (ex: obj.getCollection.get(0)).

On object the behavior is done by the proxy attribute of class tag.

Now you can reread the doc, and make simple sample to see what hibernate do.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 10:37 am 
Newbie

Joined: Wed Oct 22, 2003 9:42 am
Posts: 2
Location: France
Ok, I will reread the docs... Then I make a hibernate config of a part of my model.

I see in the forum some other hints in the following thread:
http://forum.hibernate.org/viewtopic.ph ... rent+query

I think it's this kind of request I need in addition to the config you said.

Thanks for your help,
Thierry


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 12:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
templth wrote:
I think it's this kind of request I need in addition to the config you said.


The request made in this thread is quite strange.
"select a from a left outer join b" make an outer join for nothing because you asked for a and no particular clause is used on b attributes.

The proper request is "from a" (I think an outer join is performed by Hibernate in this case), but the user don't care.

The fetch keyword is useful when you explicitly set lazy=true or have a proxy on the children and want to populate parent and children in one request.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: what about arrays?
PostPosted: Sun Nov 09, 2003 7:33 pm 
Regular
Regular

Joined: Wed Sep 10, 2003 7:09 am
Posts: 63
Hi,

I got the same question, but in a different particular case: i am using arrays.

I got a database with a high number of tables, and all relations are made by many-to-one or array collections. One of those tables ir a 'directory table', including the root directory that contains ALL the objects of ALL tables of the database. When I load the root directory, I'm load the intire daatabase!

How can I prevent that?

1) Using lazy="true" is not a solution, because I am using arrays.

2) Using outer-joins is not a solution because my queries all require diferente graph scopes.

3) using manual fetching is not a solution, because some of these tables (includind the 'directory table') are recursive, ie, they have foreign keys to the same table.

How can I solve this problem? Is there any other solutions beside these three?

Thanks in advance,
Joao Rangel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 09, 2003 7:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use proxies?


Really, the problem is that you use arrays. Don't. Arrays are bad. The JVM gives me no way to proxy them.


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