Hello forum, I need you solve me one trouble.
I need to map the flowwing classes hierarchy:
AbstractMachine (Abstract)
+ TCPIP_Machine (Abstract)
+ Pick800
+ Pick800I
+ ... in follow versions
+ USB_Machine
+ UPick900
+ ...in fllow versions
We are developing a software that have to transfer and retrieve data to/from some machines. We are designing the database creating only ABSTRACTMACHINE, TCPIP_MACHINE and USB_MACHINE tables, because the following software versions must be able to comunicate with more machines, so we can't create a "table per subclass", in other words, we can't create PICK800, PICK800I, ... tables. But, when I load a machine from database, it must be a Pick800 class, or Pick800I class.
How would you design this database/hibernate mapping?
Thanks for all.
In this moment I'm using two inheritance strategies -->
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="Model.Entities.Machines.AbstractMachine, Model" table="MACHINE">
<id name="Id" column="ID" type="Int32" unsaved-value="-1">
<generator class="identity"/>
</id>
<discriminator column="MODEL" type="String"/>
<property name="Name" column="NAME" type="String"/>
<property name="Description" column="DESCRIPTION" type="String"/>
<property name="Supplier" column="SUPPLIER" type="String"/>
<property name="Hotline" column="HOTLINE" type="String"/>
<property name="Email" column="EMAIL" type="String"/>
<property name="Web" column="WEB" type="String"/>
<joined-subclass name="Model.Entities.Machines.TCPIP_Machine, Model" table="TCPIP_MACHINE" lazy="false">
<key column="ID"/>
<property name="Ip" column="IP" type="String"/>
<property name="Port" column="PORT" type="Int32"/>
<property name="Mac" column="MAC" type="String"/>
</joined-subclass>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<subclass name="Model.Entities.Machines.Pick800Machine, Model" extends="Model.Entities.Machines.TCPIP_Machine, Model" lazy="false" discriminator-value="Pick800">
<property name="Merda"/>
</subclass>
</hibernate-mapping>