-->
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.  [ 2 posts ] 
Author Message
 Post subject: Can "many-to-one" in turn contains a "one-to-
PostPosted: Sun Nov 02, 2003 10:03 pm 
Beginner
Beginner

Joined: Thu Sep 04, 2003 2:52 am
Posts: 29
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?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 03, 2003 12:31 pm 
Regular
Regular

Joined: Tue Sep 16, 2003 11:35 am
Posts: 93
Location: San Francisco, CA
Dont you have

Element *-- ElementType *-- Protocol

? In which case you one have one protocol per element. Also, I don't think you can create a property in one class (Element) that references another (Protocol) by jumping over the intermediate table that connects them (ElementType).


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