Hi all,
I have an Element(id,name,type) ,the type maps to a ElementType(id,name,desc) class,Now I want to add a property(protocol) to ElementType. Protocol(id,name) is a seperate class.
Before add:(type is a component in Element)
--------
<hibernate-mapping ...>
<many-to-one
name="type"
class="element.ElementType"
column="element_type_id"
cascade="none"
/>
</hibernate-mapping>
Now the property would result in a "one-to-many" relation in the type.Because one element type could have more than one protocols. So
would be:
-----
<hibernate-mapping ...>
<many-to-one
name="type"
class="element.ElementType"
column="element_type_id"
cascade="none"
>
<set name="protocols" table="ElementType_ProtocolType" cascade="all">
<key column="type_id"/>
<many-to-many class="ProtocolType" column="PROTOCOL_ID" outer-join="auto"/>
</set>
</many-to-one>
</hibernate-mapping>
create table tbl_protocol_type (
PROTOCOL_ID NUMBER,
VERSION VARCHAR2(10) DEFAULT '',
constraint PK_TBL_PROTOCOL_TYPE primary key (ID)
);
is this right?
|