-->
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: Additional query for left outher join fetching of subtypes
PostPosted: Tue Mar 02, 2010 5:10 am 
Newbie

Joined: Fri Feb 26, 2010 9:09 am
Posts: 10
In some object-mappings, I have collections of subobjects:
Code:
<class name="MainObject"....>
... 
  <bag name="subList" cascade="save-update" lazy="false" inverse="true">
      <key column="ID"/>
      <one-to-many entity-name="SubObject"/>
    </bag>
</class>


In some cases, these subobjects have different types,
e.g.
Code:
public class SubObjectType1 extends SubObject


The subobject-types are stored on different tables as the super-object (I don't use discriminators)
and they are declared as <joined-subclass in the corresponding mapping.


For reading the subList in the MainObject, I use Join-Fetching.
Reading the MainObject results in the following second SQL-Statement for the collection:
Code:
SELECT ...
FROM SubObject s
LEFT OUTER JOIN SubObjectType s1 ON s.ID = s1.ID
WHERE s.ID = 'xxxxxxx';



Is it possible to add an additional restriction to the LEFT OUTER JOIN so that the statement will look like this:
Code:
SELECT ...
FROM SubObject s
LEFT OUTER JOIN SubObjectType s1 ON s.ID = s1.ID [b]AND s.orgUnit = s1.orgUnit[/b]
WHERE s.ID = 'xxxxxxx';


I think if I use a composite-id in the mappings, this query will be generated automatically.
But is there a way to do this without using a composite-id - maybe with another fetching-strategy?


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.