-->
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.  [ 4 posts ] 
Author Message
 Post subject: Transparent outer-join
PostPosted: Wed Oct 19, 2005 6:34 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Hi

I have trouble with understanding when NHibernate uses outer-joins. According to the docs, when I have "hibernate.use_outer_join" set to true and "hibernate.max_fetch_depth" >=1 , all many-to-one relations should be fetched using the joins - or I am misunderstanding something.
http://www.hibernate.org/hib_docs/reference/en/html/session-configuration.html#configuration-optional-outerjoin

Actually I noticed no difference in generated queries, with different configuration values ( always a bunch of selects, number of objects X number of relations).
The only way when NHibernate issued single query with join is using "left join fetch object.relation" in the the HQL query.

Can anyone tell me how to force "outer joins" without explicitly specifing them in all queries?

_________________
michal


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 10:10 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Ok, after some investigation I see it's a stupid question.

I've read in the Hibernate FAQ: The session is a transaction-level cache of persistent objects. So if I load an object in the first query, then I don't need any join (and any futher selects for relations) when fetching object graph, e.g. when I do "select from customers" and then "select from orders" ( many orders -> 1 customer) within one session, NHibernate need only one "flat" select to load the orders. I can also force using "outer join" with "fetch" HQL keyword in the orders query: "select from orders o left join fetch o.customer".

IMHO it could be great if NH would use "join" or "flat query" depending on that the related object is already in the session or not, but I understand that it is hard (or impossible) to implement.

And the question:
Only one thing is still unclear for me - what is fetch=join and outer-join=true purpose ? It appears useless for me according to the above.

_________________
michal


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 11:17 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
outer-join affects only Get and Load, and possibly criteria queries, as far as I understand. In HQL you need to write all the joins explicitly.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 24, 2005 10:08 am 
Ok, I understand , I will check it later. Thanks for the answer.


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