Hello,
I have definded two mapping to the same database table, you can read it later. I do it because I want a Project and another ProjectExtended that have herency from Project and include more bags.
The problem is that when requeste the follow HqlString:
select distinct p from Project as p where p.ProjectNumber LIKE %
I get a IList with the same two times. One to class Project and other to ProjectExtended. By example, If the table has three rows I get six object: three Project and three ProjectExtended.
What is the problem?
Hibernate version:1.0.1
Mapping documents:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="GEP.Exides.Instrumentation.Bussiness.Projects.Model.Project, GEP.Exides.Instrumentation.Bussiness" table="GEPIN_ING_PROJECT">
<id name="Id" column="ID" type="Decimal" unsaved-value="-1">
<generator class="sequence">
<param name="sequence">GEPIN_ING_PROJECT_SEQ</param>
</generator>
</id>
<property name="Initiator" column= "INITIATOR" type="AnsiString" length="9"/>
<property name="ProjectNumber" column="PROJECT_NUMBER" type="AnsiString" length="20" not-null="true"/>
<property name="Moc" column= "MOC" type="AnsiString" length="20"/>
<property name="Description" column="DESCRIPTION" type="AnsiString" length="400"/>
<property name="Notes" column="NOTES" type="AnsiString" length="400"/>
<property name="Remarks" column="REMARKS" type="AnsiString" length="400"/>
<bag name="Locations" table="GEPIN_ING_PROJECTLOC" lazy="false" cascade="all" inverse="true" order-by="ID ASC">
<key column="PROJECT_ID"/>
<one-to-many class="GEP.Exides.Instrumentation.Bussiness.Projects.Model.ProjectLocation, GEP.Exides.Instrumentation.Bussiness"/>
</bag>
<property name="LastUpdateDate" column="LAST_UPDATE_DATE" type="DateTime" not-null="true"/>
<property name="LastUpdatedBy" column="LAST_UPDATED_BY" type="AnsiString" length="9" not-null="true"/>
<property name="CreationDate" column="CREATION_DATE" type="DateTime" not-null="true"/>
<property name="CreatedBy" column="CREATED_BY" type="AnsiString" length="9" not-null="true"/>
<property name="DeleteMark" column="DELETE_MARK" type="Decimal" not-null="true"/>
</class>
</hibernate-mapping>
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="GEP.Exides.Instrumentation.Bussiness.Projects.Model.ProjectExtended, GEP.Exides.Instrumentation.Bussiness" table="GEPIN_ING_PROJECT">
<id name="Id" column="ID" type="Decimal" unsaved-value="-1">
<generator class="sequence">
<param name="sequence">GEPIN_ING_PROJECT_SEQ</param>
</generator>
</id>
<property name="Initiator" column= "INITIATOR" type="AnsiString" length="9"/>
<property name="ProjectNumber" column="PROJECT_NUMBER" type="AnsiString" length="20" not-null="true"/>
<property name="Moc" column= "MOC" type="AnsiString" length="20"/>
<property name="Description" column="DESCRIPTION" type="AnsiString" length="400"/>
<property name="Notes" column="NOTES" type="AnsiString" length="400"/>
<property name="Remarks" column="REMARKS" type="AnsiString" length="400"/>
<bag name="Locations" table="GEPIN_ING_PROJECTLOC" lazy="false" cascade="all" inverse="true" order-by="ID ASC">
<key column="PROJECT_ID"/>
<one-to-many class="GEP.Exides.Instrumentation.Bussiness.Projects.Model.ProjectLocation, GEP.Exides.Instrumentation.Bussiness"/>
</bag>
<bag name="TypicalLoops" table="GEPIN_ING_TYPICALLOOP_ILD" lazy="false" cascade="all" inverse="true" order-by="ID ASC">
<key column="PROJECT_ID"/>
<one-to-many class="GEP.Exides.Instrumentation.Bussiness.Typicals.Model.TypicalLoop, GEP.Exides.Instrumentation.Bussiness"/>
</bag>
<bag name="InstrumentIndex" table="GEPIN_ING_PROJECTOBJ" lazy="false" cascade="all" inverse="true" order-by="ID ASC">
<key column="PROJECT_ID"/>
<one-to-many class="GEP.Exides.Instrumentation.Bussiness.Projects.Model.ProjectInstrumentIndex, GEP.Exides.Instrumentation.Bussiness"/>
</bag>
<bag name="Sfdb" table="GEPIN_ING_PROJECTOBJ" lazy="false" cascade="all" inverse="true" order-by="ID ASC">
<key column="PROJECT_ID"/>
<one-to-many class="GEP.Exides.Instrumentation.Bussiness.Projects.Model.ProjectSfdb, GEP.Exides.Instrumentation.Bussiness"/>
</bag>
<bag name="Revisions" table="GEPIN_ING_REVISION_CONNECTION" lazy="false" cascade="all" inverse="true" order-by="ID ASC">
<key column="PROJECT_ID"/>
<one-to-many class="GEP.Exides.Instrumentation.Bussiness.Revision.Model.RevisionConnection, GEP.Exides.Instrumentation.Bussiness"/>
</bag>
<property name="LastUpdateDate" column="LAST_UPDATE_DATE" type="DateTime" not-null="true"/>
<property name="LastUpdatedBy" column="LAST_UPDATED_BY" type="AnsiString" length="9" not-null="true"/>
<property name="CreationDate" column="CREATION_DATE" type="DateTime" not-null="true"/>
<property name="CreatedBy" column="CREATED_BY" type="AnsiString" length="9" not-null="true"/>
<property name="DeleteMark" column="DELETE_MARK" type="Decimal" not-null="true"/>
</class>
</hibernate-mapping>
Name and version of the database you are using: OracleCode: