I have a Location class that has a many-to-many relationship with a LegalLandDescription class.
The LegalLandDescription class has 2 concrete subclasses Nts and Dls. The Nts and Dls each have a unique set of mapped properties.
I'd like to write a query that will include both Nts and Dls entities.
I know that I can create a view that will do this for me, but I'm hopeful
that is is not necessary. Another option I believe is to have the entire class retrieved as part of the result-set.
If someone with more experience could put together a quick sample of wha the HQL would look like that would be great.
Thanks in advance
Here are my mapping documents:
Location
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Model.Domain" namespace="Model.Domain">
<class name="Location" table="LOCATION">
<id name="LocationId" column="LOCATION_ID" type="Int64" unsaved-value="0">
<generator class="native"/>
</id>
<many-to-one name="LocationPosition" column="LOCATION_POSITION_TYPE_ID" class="LocationPosition" />
<bag name="ProjectClasses" table="PROJECT_CLASS_LOCATION" cascade="all" inverse="true" outer-join="true">
<key column="PROJECT_CLASS_ID" />
<many-to-many column="location_id"
class="Model.Domain.ProjectClass, Model.Domain" />
</bag>
<bag name="LegalLandDescriptions" table="LOCATION_LEGAL_LAND_DESCRIPTION_XREF" cascade="all" outer-join="true">
<key column="LOCATION_ID" />
<many-to-many column="LEGAL_LAND_DESCRIPTION_ID"
class="Model.Domain.LegalLandDescription, Model.Domain" />
</bag>
<bag name="Coordinates" table="LOCATION_COORDINATE_XREF" cascade="all" outer-join="true">
<key column="LOCATION_ID"/>
<many-to-many column="COORDINATE_ID"
class="Model.Domain.Coordinate, Model.Domain"/>
</bag>
</class>
</hibernate-mapping>
LegalLandDescriptionCode:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Model.Domain" namespace="Model.Domain">
<class name="LegalLandDescription" table="LEGAL_LAND_DESCRIPTION">
<id name="Id" column="LEGAL_LAND_DESCRIPTION_ID" type="Int64" unsaved-value="0">
<generator class="native"/>
</id>
<bag name="Locations" table="LOCATION_LEGAL_LAND_DESCRIPTION_XREF" inverse="true"
cascade="all" outer-join="true">
<key column="LEGAL_LAND_DESCRIPTION_ID" />
<many-to-many column="LOCATION_ID"
class="Model.Domain.Location, Model.Domain"/>
</bag>
</class>
</hibernate-mapping>
DlsCode:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
assembly="Model.Domain" namespace="Model.Domain">
<joined-subclass name="DlsLocation" table="DLS_LOCATION" extends="LegalLandDescription"
dynamic-insert="true" dynamic-update="true">
<key column="DLS_LOCATION_ID"/>
<property column="LSD" type="Int32" name="Lsd" />
<property column="SEC" type="Int32" name="Sec" />
<property column="TWP" type="Int32" name="Twp" not-null="true" />
<property column="RGE" type="Int32" name="Rge" not-null="true" />
<property column="MER" type="Int32" name="Mer" not-null="true" />
</joined-subclass>
</hibernate-mapping>
NtsCode:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Model.Domain" namespace="Model.Domain">
<joined-subclass name="NtsLocation" table="NTS_LOCATION"
extends="LegalLandDescription" dynamic-insert="true" dynamic-update="true">
<key column="NTS_LOCATION_ID"/>
<property column="QTR" type="Char" name="Qtr" length="1" />
<property column="UNIT" type="Int32" name="Unit" />
<property column="BLOCK" type="Char" name="Block" length="1" />
<property column="MAP" type="Int32" name="Map"/>
<property column="SUB" type="Char" name="Sub" length="1"/>
<property column="Sheet" type="Int32" name="Sheet"/>
</joined-subclass>
</hibernate-mapping>
[/b][/code]