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.  [ 1 post ] 
Author Message
 Post subject: Hibernate and outer joins
PostPosted: Wed Jul 07, 2010 7:38 pm 
Newbie

Joined: Tue Jul 06, 2010 10:41 pm
Posts: 1
Hi,
I was wondering if any fellow hibernate users could clear up a point of confusion for me. I've searched around on the web but I can't find a definitive answer. In the absence of HQL or Criteria "overrides" will/must hibernate always use left outer joins to eagerly fetch data for single valued related entities?

My own experience is this

-When the relationship is defined by the top level entity being queried (depth 0), hibernate will use an inner join to the related table (depth 1) if the @ManyToOne is marked optional=false
-When the relationship is owned by the top level entity being queried (depth 0), hibernate will use an outer join to the related table (depth 1) if the @ManyToOne is marked as optional=true

These two points make perfect sense to me. My third observation is what confuses me

-Related entities more then 1 level deep in the object graph are retrieved using an outer join, completely irrespective of the value of the optional on the @ManyToOne or @OneToOne relationship.

Is this just how it works? Is it possible to force inner joins to be used for optional=false relationships? It seems inconsistent but I'm probably missing something. Currently using 3.3.2 GA.


Thanks.


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

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.