zafarjcp wrote:
Can you please explain what you figer out in your code. because i am also stuck in this issue
Hi... Not sure I can remember exactly what I did to fix this issue.
The application has evolved quite a bit since then.
Here is the HQL as it is today:
Code:
string hsqlQuery =
"SELECT p.ProjectName, c.BottomHoleLocation, p.Id, c.EventSequence, c.EventLocation, c.ProjectAfe, s, j, o, pd, p, p.IsArchived " +
" FROM Project p " +
" INNER JOIN p.ProjectClasses c " +
" LEFT JOIN p.Strike s " +
" LEFT JOIN p.Jurisdiction j " +
" LEFT JOIN p.OperatingTeam o " +
" LEFT JOIN c.Product pd " +
" INNER JOIN c.BottomHoleLocation bh ";
Here are the mapping files. Hope this helps...
ProjectCode:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" Assembly="Domain" namespace="Domain">
<class name="Project" table="PROJECT">
<id name="Id" access="field.pascalcase-underscore" column="PROJECT_ID" type="Int64" unsaved-value="0">
<generator class="native"/>
</id>
<property name="ProjectName" access="field.pascalcase-underscore" column="PROJECT_NAME" length="50"/>
<many-to-one name="ProjectType" access="field.pascalcase-underscore" column="PROJECT_TYPE_ID" class="ProjectType" />
<many-to-one name="OperatingTeam" access="field.pascalcase-underscore" column="OperatingTeamId" class="OperatingTeam"/>
<many-to-one name="Strike" access="field.pascalcase-underscore" column="Strike_Id" class="Strike"/>
<many-to-one name="Jurisdiction" access="field.pascalcase-underscore" column="Jurisdiction_Id" class="Jurisdiction"/>
<property name="ArchiveComments" access="field.pascalcase-underscore" column="ArchiveComments" length="255"/>
<property name="IsArchived" access="field.pascalcase-underscore" column="IsArchived" />
<many-to-one name="ArchiveStatus" access="field.pascalcase-underscore" column="ArchiveStatusId" class="ArchiveStatus" />
<bag name="HistoryEntries" cascade="all-delete-orphan" access="field.pascalcase-underscore" inverse="true">
<key column="ProjectId" />
<one-to-many class="HistoryEntry" />
</bag>
<bag name="ProjectClasses" cascade="all-delete-orphan" access="field.pascalcase-underscore">
<key column="ProjectId" />
<one-to-many class="ProjectClass" />
</bag>
</class>
</hibernate-mapping>
Project ClassCode:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
assembly="WellAccelerator.Domain" namespace="WellAccelerator.Domain">
<class name="ProjectClass" table="PROJECT_CLASS" discriminator-value="PC" lazy="false">
<id name="Id" access="field.pascalcase-underscore" column="PROJECT_CLASS_ID" type="Int64" unsaved-value="0">
<generator class="native"/>
</id>
<discriminator column="CLASS_CODE" type="String" length="4"/>
<many-to-one name="Project" class="Project" column="ProjectId" access="field.pascalcase-underscore"/>
<property column="PROJECT_CLASS_TYPE"
type="WellAccelerator.Domain.ProjectClassCode, WellAccelerator.Domain"
name="ProjectClassCode" access="field.pascalcase-underscore" not-null="true"
/>
<bag name="Contacts" access="field.pascalcase-underscore" table="ProjectContact" cascade="all" lazy="false">
<key column="ProjectClassId" />
<one-to-many class="Domain.ProjectContact, Domain" />
</bag>
<many-to-one name="ProjectAfe" access="field.pascalcase-underscore" class="ProjectAfe" column="ProjectAfeId" cascade="save-update"/>
<many-to-one name="Product" access="field.pascalcase-underscore" column="ProductId" class="Product"/>
<many-to-one class="LegalLandDescription" name="SurfaceLocation" access="field.pascalcase-underscore" cascade="all"/>
</class>
</hibernate-mapping>