I have a class hierachy using joined sublasses. I then try and use an HQL query to return a List of objects but the class returned is an instance of the abstract superclass of the object I expect to have returned.
The class of the returned object is shown in my debugger as EntityImpl, whereas I was expecting a IndividualImpl.
Debugger shows "[0]= EntityImpl$$EnhancerByCGLIB$$de451a6c "
The HQL query is
"FROM com.kazgroup.courtlink.domain.impl.common.EntityImpl entity, com.kazgroup.courtlink.domain.impl.proceeding.EntityProceedingImpl ep WHERE entity.entityId = ep.key.entityImpl.entityId AND ep.key.proceedingImpl.proceedingNumber = :p AND ep.key.proceedingRoleImpl.code = :role ORDER BY entity.displayName asc "
Hibernate version: 3.0.5
Mapping documents: <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping > <class name="com.kazgroup.courtlink.domain.impl.common.EntityImpl" table="ENTITY" dynamic-update="true" optimistic-lock="version" >
<id name="entityId" column="ENTITY_ID" type="java.lang.Long" > <generator class="sequence"> <param name="sequence">ENTITY_ID</param> <!-- To add non XDoclet generator parameters, create a file named hibernate-generator-params-EntityImpl.xml containing the additional parameters and place it in your merge dir. --> </generator> </id>
<version name="lockVersion" column="LOCK_VERSION" type="java.lang.Long" />
<property name="entityTypeString" type="java.lang.String" update="true" insert="true" column="ENTITY_TYPE" not-null="true" unique="false" />
<property name="entityStatus" type="java.lang.String" update="true" insert="true" column="ENTITY_STATUS" unique="false" />
<property name="preferredContactTypeString" type="java.lang.String" update="true" insert="true" column="PREFERRED_CONTACT_TYPE" unique="false" />
<set name="contacts" lazy="true" inverse="true" cascade="all" sort="unsorted" >
<key column="ENTITY_ID" > </key>
<one-to-many class="com.kazgroup.courtlink.domain.impl.common.ContactImpl" />
</set>
<property name="modifiedDate" type="java.util.Date" update="true" insert="true" column="MODIFIED_DATE" not-null="true" unique="false" />
<property name="modifiedByUser" type="java.lang.String" update="true" insert="true" column="MODIFIED_BY_USER" not-null="true" unique="false" />
<!-- Display name. This is added seperately because of bug or anomoly in XDoclet when referencing joined subclasses with overridden methods. --> <property name="displayName" type="java.lang.String" update="true" insert="true" column="DISPLAY_NAME" unique="false" />
<joined-subclass name="com.kazgroup.courtlink.domain.impl.document.DocumentRecipientImpl" table="DOCUMENT_RECIPIENT" > <key column="ENTITY_ID" />
<property name="surname" type="java.lang.String" update="true" insert="true" column="SURNAME" not-null="true" unique="false" />
<property name="givenName" type="java.lang.String" update="true" insert="true" column="GIVEN_NAME" not-null="true" unique="false" />
</joined-subclass> <joined-subclass name="com.kazgroup.courtlink.domain.impl.participant.IndividualImpl" table="INDIVIDUAL" > <key column="ENTITY_ID" />
<property name="givenName" type="java.lang.String" update="true" insert="true" column="GIVEN_NAME" unique="false" />
<property name="surname" type="java.lang.String" update="true" insert="true" column="SURNAME" not-null="true" unique="false" />
</joined-subclass> <joined-subclass name="com.kazgroup.courtlink.domain.impl.participant.LegalPractitionerImpl" table="LEGAL_PRACTITIONER" > <key column="ENTITY_ID" />
<property name="practitionersState" type="java.lang.String" update="true" insert="true" column="PRACTITIONERS_STATE" unique="false" />
<property name="pcn" type="java.lang.String" update="true" insert="true" column="PCN" unique="false" />
<property name="surname" type="java.lang.String" update="true" insert="true" column="SURNAME" not-null="true" unique="false" />
<property name="givenName" type="java.lang.String" update="true" insert="true" column="GIVEN_NAME" unique="false" />
<property name="practitionersFirm" type="java.lang.String" update="true" insert="true" column="PRACTITIONERS_FIRM" unique="false" />
<many-to-one name="legalPractitionerTypeImpl" class="com.kazgroup.courtlink.domain.impl.refdata.LegalPractitionerTypeImpl" cascade="none" outer-join="auto" update="true" insert="true" column="LEGAL_PRACTITIONER_TYPE" not-null="true" />
</joined-subclass> <joined-subclass name="com.kazgroup.courtlink.domain.impl.participant.OrganisationImpl" table="ORGANISATION" > <key column="ENTITY_ID" />
<property name="organisationName" type="java.lang.String" update="true" insert="true" column="ORGANISATION_NAME" not-null="true" unique="false" />
<property name="abn" type="java.lang.String" update="true" insert="true" column="ABN" unique="false" />
<property name="acn" type="java.lang.String" update="true" insert="true" column="ACN" unique="false" />
<property name="fui" type="java.lang.String" update="true" insert="true" column="FUI" unique="false" />
<property name="isFeeExempt" type="java.lang.String" update="true" insert="true" column="FEE_EXEMPT" not-null="true" unique="false" />
</joined-subclass> <joined-subclass name="com.kazgroup.courtlink.domain.impl.registry.ExternalAgencyImpl" table="EXTERNAL_AGENCY" > <key column="ENTITY_ID" />
<property name="agencyType" type="java.lang.String" update="true" insert="true" column="EXTERNAL_AGENCY_TYPE" not-null="true" unique="false" />
<property name="agencyName" type="java.lang.String" update="true" insert="true" column="AGENCY_NAME" not-null="true" unique="false" />
<property name="contactName" type="java.lang.String" update="true" insert="true" column="CONTACT_NAME" not-null="false" unique="false" />
<property name="abn" type="java.lang.String" update="true" insert="true" column="ABN" unique="false" />
<property name="acn" type="java.lang.String" update="true" insert="true" column="ACN" unique="false" />
<property name="feeExempt" type="java.lang.String" update="true" insert="true" column="FEE_EXEMPT" not-null="true" unique="false" />
<property name="effectiveFrom" type="java.util.Date" update="true" insert="true" column="EFFECTIVE_FROM" not-null="true" unique="false" />
<property name="effectiveTo" type="java.util.Date" update="true" insert="true" column="EFFECTIVE_TO" not-null="true" unique="false" />
</joined-subclass> <joined-subclass name="com.kazgroup.courtlink.domain.impl.registry.OrderMakerImpl" table="ORDER_MAKER" > <key column="ENTITY_ID" />
<property name="givenName" type="java.lang.String" update="true" insert="true" column="GIVEN_NAME" not-null="true" unique="false" />
<property name="surname" type="java.lang.String" update="true" insert="true" column="SURNAME" not-null="true" unique="false" />
<property name="specialityArea" type="java.lang.String" update="true" insert="true" column="SPECIALITY_AREA" not-null="true" unique="false" />
<property name="preferredPrefix" type="java.lang.String" update="true" insert="true" column="PREFERRED_PREFIX" not-null="false" unique="false" />
<property name="preferredSuffix" type="java.lang.String" update="true" insert="true" column="PREFERRED_SUFFIX" not-null="false" unique="false" />
<property name="eforumName" type="java.lang.String" update="true" insert="true" column="EFORUM_NAME" not-null="false" unique="false" />
<property name="comments" type="java.lang.String" update="true" insert="true" column="COMMENTS" not-null="false" unique="false" />
<property name="seniority" type="java.lang.Long" update="true" insert="true" column="SENIORITY" not-null="true" unique="false" />
<property name="orderMakerTypeString" type="java.lang.String" update="true" insert="true" column="ORDER_MAKER_TYPE" not-null="true" unique="false" />
<set name="orderMakerAppointments" lazy="true" inverse="true" cascade="all" sort="unsorted" >
<key column="ENTITY_ID" > </key>
<one-to-many class="com.kazgroup.courtlink.domain.impl.registry.OrderMakerAppointmentImpl" />
</set>
</joined-subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs: N/A
Name and version of the database you are using: Oracle 10g
The generated SQL (show_sql=true): select entityimpl0_.ENTITY_ID as ENTITY1_0_, entityproc1_.PROCEEDING_NUMBER as PROCEEDING1_1_, entityproc1_.ENTITY_ID as ENTITY2_1_, entityproc1_.PROCEEDING_ROLE as PROCEEDING3_1_, entityimpl0_.LOCK_VERSION as LOCK2_12_0_, entityimpl0_.ENTITY_TYPE as ENTITY3_12_0_, entityimpl0_.ENTITY_STATUS as ENTITY4_12_0_, entityimpl0_.PREFERRED_CONTACT_TYPE as PREFERRED5_12_0_, entityimpl0_.MODIFIED_DATE as MODIFIED6_12_0_, entityimpl0_.MODIFIED_BY_USER as MODIFIED7_12_0_, entityimpl0_.DISPLAY_NAME as DISPLAY8_12_0_, entityimpl0_1_.SURNAME as SURNAME13_0_, entityimpl0_1_.GIVEN_NAME as GIVEN3_13_0_, entityimpl0_2_.GIVEN_NAME as GIVEN2_14_0_, entityimpl0_2_.SURNAME as SURNAME14_0_, entityimpl0_3_.PRACTITIONERS_STATE as PRACTITI2_15_0_, entityimpl0_3_.PCN as PCN15_0_, entityimpl0_3_.SURNAME as SURNAME15_0_, entityimpl0_3_.GIVEN_NAME as GIVEN5_15_0_, entityimpl0_3_.PRACTITIONERS_FIRM as PRACTITI6_15_0_, entityimpl0_3_.LEGAL_PRACTITIONER_TYPE as LEGAL7_15_0_, entityimpl0_4_.ORGANISATION_NAME as ORGANISA2_16_0_, entityimpl0_4_.ABN as ABN16_0_, entityimpl0_4_.ACN as ACN16_0_, entityimpl0_4_.FUI as FUI16_0_, entityimpl0_4_.FEE_EXEMPT as FEE6_16_0_, entityimpl0_5_.EXTERNAL_AGENCY_TYPE as EXTERNAL2_17_0_, entityimpl0_5_.AGENCY_NAME as AGENCY3_17_0_, entityimpl0_5_.CONTACT_NAME as CONTACT4_17_0_, entityimpl0_5_.ABN as ABN17_0_, entityimpl0_5_.ACN as ACN17_0_, entityimpl0_5_.FEE_EXEMPT as FEE7_17_0_, entityimpl0_5_.EFFECTIVE_FROM as EFFECTIVE8_17_0_, entityimpl0_5_.EFFECTIVE_TO as EFFECTIVE9_17_0_, entityimpl0_6_.GIVEN_NAME as GIVEN2_18_0_, entityimpl0_6_.SURNAME as SURNAME18_0_, entityimpl0_6_.SPECIALITY_AREA as SPECIALITY4_18_0_, entityimpl0_6_.PREFERRED_PREFIX as PREFERRED5_18_0_, entityimpl0_6_.PREFERRED_SUFFIX as PREFERRED6_18_0_, entityimpl0_6_.EFORUM_NAME as EFORUM7_18_0_, entityimpl0_6_.COMMENTS as COMMENTS18_0_, entityimpl0_6_.SENIORITY as SENIORITY18_0_, entityimpl0_6_.ORDER_MAKER_TYPE as ORDER10_18_0_, case when entityimpl0_1_.ENTITY_ID is not null then 1 when entityimpl0_2_.ENTITY_ID is not null then 2 when entityimpl0_3_.ENTITY_ID is not null then 3 when entityimpl0_4_.ENTITY_ID is not null then 4 when entityimpl0_5_.ENTITY_ID is not null then 5 when entityimpl0_6_.ENTITY_ID is not null then 6 when entityimpl0_.ENTITY_ID is not null then 0 end as clazz_0_, entityproc1_.LOCK_VERSION as LOCK4_83_1_, entityproc1_.IS_PRIMARY as IS5_83_1_, entityproc1_.MODIFIED_DATE as MODIFIED6_83_1_, entityproc1_.MODIFIED_BY_USER as MODIFIED7_83_1_ from ENTITY entityimpl0_ left outer join DOCUMENT_RECIPIENT entityimpl0_1_ on entityimpl0_.ENTITY_ID=entityimpl0_1_.ENTITY_ID left outer join INDIVIDUAL entityimpl0_2_ on entityimpl0_.ENTITY_ID=entityimpl0_2_.ENTITY_ID left outer join LEGAL_PRACTITIONER entityimpl0_3_ on entityimpl0_.ENTITY_ID=entityimpl0_3_.ENTITY_ID left outer join ORGANISATION entityimpl0_4_ on entityimpl0_.ENTITY_ID=entityimpl0_4_.ENTITY_ID left outer join EXTERNAL_AGENCY entityimpl0_5_ on entityimpl0_.ENTITY_ID=entityimpl0_5_.ENTITY_ID left outer join ORDER_MAKER entityimpl0_6_ on entityimpl0_.ENTITY_ID=entityimpl0_6_.ENTITY_ID, ENTITY_PROCEEDING entityproc1_, ENTITY entityimpl2_, PROCEEDING proceeding3_, PROCEEDING_ROLE proceeding4_ where entityproc1_.PROCEEDING_ROLE=proceeding4_.PROCEEDING_ROLE and entityproc1_.PROCEEDING_NUMBER=proceeding3_.PROCEEDING_NUMBER and entityproc1_.ENTITY_ID=entityimpl2_.ENTITY_ID and entityimpl0_.ENTITY_ID=entityimpl2_.ENTITY_ID and proceeding3_.PROCEEDING_NUMBER=? and proceeding4_.PROCEEDING_ROLE=? order by entityimpl0_.DISPLAY_NAME asc
Debug level Hibernate log excerpt:
|