-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Joined subclassing with property overrides
PostPosted: Mon Jul 30, 2007 12:31 pm 
Regular
Regular

Joined: Tue May 31, 2005 9:55 am
Posts: 67
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 30, 2007 1:14 pm 
Regular
Regular

Joined: Tue May 31, 2005 9:55 am
Posts: 67
If it is not already obvious, I meant discriminated subclass and not joined.

craig


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.