-->
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 Forcing Inner Join of Mapped Entities
PostPosted: Thu May 02, 2013 7:27 pm 
Beginner
Beginner

Joined: Sat Sep 24, 2005 11:04 pm
Posts: 21
Version: hibernate-core-3.5.6

Ok, so here's the deal (and as a disclaimer it's quite possible that this may be due to a lack of understanding on my part)... I'm trying to select a mapped entity three levels deep in my object graph. The second level entity is aliased and qualified with a left outer join in my HQL statement.

Code:
select child1.child2 from Parent p
left join p.child1 as child1

which results in something along the lines of:
Code:
select child2_.col1, child2_.col2
from tblParent parent_
left outer join tblChild1 child1_ on child1_.id = parent_.id
inner join tblChild2 child2_ on child2_.id = child1_.child2Id

I'm aware of the nuances of using an implicit join in HQL, but wouldn't expect this to apply if the direct parent (child1 in this case) is explicitly qualified with a left outer join. As you have probably inferred at this point, this is filtering my results to include only those with non-null values for child2. I'm most likely missing something obvious here, but unfortunately the solution has proven to be most elusive thus far. For the sake of specificity, child1 is a one-to-one from the root object (Parent) and child2 is a many-to-one from child1.

It's also worth mentioning that I'm building the HQL dynamically for reporting purposes. The code reads the property path from an enum which represents a field that can be included in a report. Ideally, we would like to be able to simply add an additional enum for inclusion in the report without having to modify the DAO code responsible for building the query.

Any ideas?


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.