I was wondering if overriding the same property in a joined class is valid ? I have a base class with a normal property and then create a subclass with the same property name, but assigned a formula. When I query for the base class, the derived class formulas are always evaluated. Is this because of implicity polymorphism?
Here is my hbm.xml
Code:
<?xml version="1.0" encoding="utf-16"?>
<hibernate-mapping auto-import="true" default-lazy="false" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.2">
<class name="EC.DomainModel.Canister, EC.DomainModel" table="Canister" discriminator-value="C" schema="dbo">
<id name="Id" access="property" column="Id" type="Int32" unsaved-value="0">
<generator class="native">
</generator>
</id>
<discriminator column="type" type="String" />
<property name="FillId" access="property" type="Guid">
<column name="FillId" not-null="true"/>
</property>
<property name="BuildId" access="property" type="Guid">
<column name="BuildId" not-null="true"/>
</property>
<property name="Position" access="property" type="Int32">
<column name="Position" not-null="true"/>
</property>
<property name="FillDate" access="property" type="Timestamp">
<column name="FillDate" not-null="true"/>
</property>
<property name="DateOffset" access="property" type="Timestamp">
<column name="DateOffsetDate" not-null="true"/>
</property>
<property name="Quantity" access="property" type="Int32">
<column name="Quantity" not-null="true"/>
</property>
<property name="Technician" access="property" type="String">
<column name="Technician" not-null="true"/>
</property>
<property name="PharmacistOfRecord" access="property" type="String">
<column name="PharmacistOfRecord" not-null="true"/>
</property>
<property name="IsEmpty" access="property" type="Boolean">
<column name="IsEmpty" not-null="true"/>
</property>
<property name="State" access="property" type="EC.DomainModel.CanisterState, EC.DomainModel">
<column name="State"/>
</property>
<component name="Lot" class="EC.DomainModel.Lot, EC.DomainModel" access="property">
<property name="LotNumber" access="property" type="String">
<column name="LotNumber" not-null="true"/>
</property>
<property name="ExpirationDate" access="property" type="Timestamp">
<column name="ExpirationDate" not-null="true"/>
</property>
<many-to-one name="Drug" access="property" class="EC.DomainModel.PackagedDrug, EC.DomainModel" column="PackagedDrugId" not-null="true" />
</component>
<subclass name="EC.DomainModel.SmartCanister, EC.DomainModel" discriminator-value="S">
<property name="ChipId" access="property" type="String">
<column name="ChipId"/>
</property>
<property name="CanisterId" access="property" type="Int32">
<column name="CanisterId"/>
</property>
<property name="State" access="property" type="EC.DomainModel.CanisterState, EC.DomainModel" formula="isnull((select case clu.cartridge_status
when 0 then -1
when 1 then 0
when 2 then 1
else (case when State = 1 then 0 else State end)
end
from Medicine.dbo.canister_load_unload_info clu
where ChipId = clu.chip_id), State)">
<column name="State"/>
</property>
<property name="Position" access="property" type="Int32" formula="isnull((select case clu.cartridge_status
when 2 then clu.cartridge_id
else -1
end
from Medicine.dbo.canister_load_unload_info clu
where ChipId = clu.chip_id), -1)">
<column name="Position"/>
</property>
</subclass>
</class>
</hibernate-mapping>
Thanks,
craig