Hello folks,
Got a class
Code:
class Customer : Company
And a property
Code:
class Customer { ... public CustomerInternetServiceDetail CustomerInternetServiceDetail { get; set; }... }
Trying to do polymorphic
Code:
(Customer)companyManager.FindCompanyByID( companyID );
it's instantiated w/o CustomerInternetServiceDetail. By the looks of the SQL, it's not joining or sub-selecting the CustomerInternetServiceDetail!
Full mapping follows...
Code:
<class name="Company" table="Company">
<id name="CompanyID" column="CompanyID" type="Int32" unsaved-value="0">
<generator class="identity" />
</id>
<property unique="true" column="CompanyName" type="String" name="CompanyName" not-null="true" length="250" />
<property column="CompanyTypeID" name="CompanyTypeID" not-null="true" />
<set name="Contacts" inverse="true" cascade="all" table="Contacts">
<!--jcs-cache usage="read-write" /-->
<key column="CompanyId" />
<one-to-many class="Contact" />
</set>
<set name="Addresses" inverse="true" cascade="all" table="Address">
<!--jcs-cache usage="read-write" /-->
<key column="CompanyId" />
<one-to-many class="Address" />
</set>
</class>
Code:
<joined-subclass name="Customer" table="Customer" extends="Company" >
<key column="CustomerID" />
<!-- other stuff here -->
<one-to-one name="InternetServiceDetail" class="CustomerInternetServiceDetail" cascade="all-delete-orphan" fetch="join" outer-join="true" />
</joined-subclass>
Code:
<class name="CustomerInternetServiceDetail" table="CustomerInternetServiceDetail">
<id name="CustomerInternetServiceDetailID" column="CustomerID" type="Int32">
<generator class="foreign" >
<param name="property">Customer</param>
</generator>
</id>
<one-to-one name="Customer" class="Customer" constrained="true" cascade="none" />
<!-- other stuff here -->
</class>
This works as expected though:
Code:
_session.Get( typeof(Customer), customerID)
If it's a bug in polymorphic fetch... it's scary. If there's something I missed in the mapping, I'd very much like to know what it is!
TIA,
E.