-->
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.  [ 3 posts ] 
Author Message
 Post subject: join and joined-subclass
PostPosted: Mon Aug 16, 2010 12:55 pm 
Newbie

Joined: Sun Aug 15, 2010 8:32 pm
Posts: 3
Am I correct in understanding that you cannot have a join and a joined-subclass element under one class element? If this is true how does one map this model where the join table defines a 1(subtype)-M(supertype) optional bidirectional relationship from the subtype to the supertype. The semantics of this relationship are independent of the supertype-subtype relationship. The subtype is one of several subtypes of the supertype that are defined using a table-per-class subtype mapping and therefore use the joined-subclass tag. When I try to add this relationship the mapping file does not validate. I get the standard "Content of element type class must match..." Currently using XDoclet to define hibernate mappings.

Thanks in advance for any help.

Code:
   supertype ----------|
        ^              |
        |              |
        |              |
     subtype -----< join table


relevant snippets from generated hbm.xml file that doesn't validate.

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class table="a1mel" lazy="false" name="org.unavco.pbo.mdm.model.Equipment">
    <id column="idmel" unsaved-value="null" name="id">
      <generator class="sequence">
        <param name="sequence">a1MELSeq</param>
      </generator>
    </id>
    <property name="idUNAVCO" column="eqpunavcoid"/>
    <property name="manufacturer" column="eqpmanuf"/>

    <joined-subclass name="org.unavco.pbo.mdm.equipment.model.Tiltmeter" table="a2eqp_tiltmeter">
      <key column="idmel"/>
      <property name="depth" column="depth"/>
      <property name="orientation" column="orientation"/>
      <property name="latitude" column="latitude"/>
      <property name="longitude" column="longitude"/>
      <property name="elevation" column="elevation"/>
    </joined-subclass>

<!-- supertype(1) side of 1:M definition
    <join table="timedEquipment" optional="true">
      <key column="equipmentid"/>
      <many-to-one not-null="true" column="timerid" name="timer" class="org.unavco.pbo.mdm.equipment.model.Timer"/>
    </join>

    ....

    <joined-subclass name="org.unavco.pbo.mdm.equipment.model.Timer" table="a2eqpTimer">
      <key column="idmel"/>
     <!-- collection not relevant to discussion -->
      <bag table="a3eqptimervalue" inverse="true" cascade="all, delete-orphan" name="modifiableTimerValues">
        <key column="timerid"/>
        <one-to-many class="org.unavco.pbo.mdm.equipment.model.timerValue"/>
      </bag>

<!-- collection side of 1:M relationship -->
      <set table="timedEquipment" inverse="true" name="modifiableEquipment">
        <key column="timerid"/>
        <many-to-many column="equipmentid" unique="true" class="org.unavco.pbo.mdm.model.Equipment"/>
      </set>
    </joined-subclass>

    ....

  </class>
</hibernate-mapping>



Top
 Profile  
 
 Post subject: Re: join and joined-subclass
PostPosted: Mon Aug 16, 2010 5:37 pm 
Newbie

Joined: Sun Aug 15, 2010 8:32 pm
Posts: 3
Here's an ERD of the relevant bits in the hbm.xml mapping

Image


Top
 Profile  
 
 Post subject: Re: join and joined-subclass
PostPosted: Tue Aug 31, 2010 11:07 am 
Newbie

Joined: Sun Aug 15, 2010 8:32 pm
Posts: 3
Can anybody address this please?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.