-->
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: Named Query and Inheritance
PostPosted: Thu Apr 21, 2011 11:31 am 
Newbie

Joined: Thu Apr 21, 2011 11:27 am
Posts: 4
I'm having some issues when running a named query. The class I'm setting as the return value is Organization - not abstract -, and I have a second class (which inherits from this one) called FullOrganization. I have a table per concrete class schema and everything else is working just fine, but I keep getting an exception when running the named query (which BTW doesn't provide any details).

The mapping is close to the following:

<hibernate-mapping
xmlns="urn:nhibernate-mapping-2.2"
namespace="XXX"
assembly="XXX"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:nhibernate-mapping-2.2 ..\nhibernate-mapping.xsd" auto-import="false">
<class name="Organization" table="Organizations" lazy="false">
<id name="Identity" column="Id">
<generator class="identity"/>
</id>

<property name="Name" column="Name" />
<many-to-one name="OrganizationType" column="OrganizationTypeId"/>
...
<joined-subclass name="FullOrganization" table="FullOrganizations" lazy="false">
<key column="OrganizationId"/>
...
</joined-subclass>
</class>
And the named query goes something like:

<sql-query name="OrganizationSearch" read-only="true" cacheable="false">
<return class="Organization" />
<![CDATA[
SELECT *
FROM Organizations o
INNER JOIN OrganizationTypes ot ON o.OrganizationTypeId = ot.Id
LEFT JOIN FullOrganizations fo ON o.Id = fo.OrganizationId
WHERE
// Several Filters Here
]]>
</<sql-query

How should I map the query results? Please take into account that returned objects could be instances of Organization or FullOrganization.

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.