-->
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: How to use outer join with joined-subclass
PostPosted: Fri Jul 15, 2005 12:16 pm 
Newbie

Joined: Fri Jul 15, 2005 12:04 pm
Posts: 1
I have two classes, super class and subclass. (class Foo, and class Bar extends Foo).

They use same Hibernate descriptor file:
Code:
<class name="Foo" table="foo_table" lazy="false">


   <joined-subclass name="Bar" table="far_table">


The foo_table has a raw with the specified id, but the bar_table is empty. In this case I would like the Bar object returned to me with Foo’s properties populated, but because the inner join returns no rows, I get nothing from Hibernate.
I think the way to fix it would be to force Hibernate to use outer join. Any idea on how to do it with joined-subclass?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 12:28 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
Doesn't seem like something you should want to do. Thinking in terms of OO, if there is a Foo record with no associated Bar record, then it's not really a Bar, it's a Foo (which is why your query returns no rows). So my guess is it's not possible, becuase it's not the right behavior.

You can get this kind of outer-join functionality using the <join> element with optional="true". See http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-join (I've never actually used it, just read about it).


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.