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!
|