-->
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.  [ 1 post ] 
Author Message
 Post subject: Multi level inheritance
PostPosted: Mon Apr 21, 2008 6:18 am 
Newbie

Joined: Sat Apr 07, 2007 6:53 am
Posts: 16
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>


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

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.