Hi,
I want to map a composite.
I have the following class hierarchy.
Code:
public interface IComponent {
//setters and getters for the common properties
}
public class Leaf implements IComponent{
//setters and getters for the common properties
}
public class CompositeElement implements IComponent{
//setter and getter for the common properties
//access and modifiers for the IComponent List
}
I'd like to map them in 3 tables.
Leaf[String1, String2, OID]
CompositeElement[String1, String2, OID]
CompElement_Composite[OID_CompElemet, OID_Component]
My mappings are as follows:
Code:
<hibernate-mapping>
<class name="domainlayer.Leaf" table="Leaf">
<id name="oid" type="string" unsaved-value="null" >
<column name="OID" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="String1">
<column name="String1" sql-type="varchar(255)" not-null="false"/>
</property>
<!--
The remaining properties
-->
</class>
</hibernate-mapping>
-------------
<hibernate-mapping>
<class name="domainlayer.CompositeElement" table="CompositeElement">
<id name="oid" type="string" unsaved-value="null" >
<column name="OID" sql-type="char(32)" not-null="true"/>
<generator class="uuid.hex"/>
</id>
<property name="String1">
<column name="String1" sql-type="varchar(255)" not-null="false"/>
</property>
<!--
The remaining properties
-->
[color=red]<!--
I guess my problem is here
-->[/color]
<bag name="childs" table="CompElement_Composite" cascade="all">
<key>
<column name="OID_CompElemet" not-null="true"/>
</key>
<many-to-many class="domainlayer.[color=red]??[/color]">
<column name="OID_Component" not-null="true"/>
</many-to-many>
</bag>
</class>
</hibernate-mapping>
My unanswered questions is:
1- In the Bag I can-t map the interface. So wich class should I map?
Any help is apreciated.
thanks
Matauy