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>