-->
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: Using key-many-to-one in composite-id
PostPosted: Tue Sep 14, 2004 11:31 am 
Newbie

Joined: Mon Aug 30, 2004 2:48 pm
Posts: 11
Hibernate version3.0alpha:

Mapping documents:

<hibernate-mapping package="com.matt">
<class name="Field" table="fc_fields" >
<composite-id name="FieldId" class="FieldId">
<key-property name="fcId" column="fc_id" type="int" />
<key-many-to-one name="fldId" column="fld_id" type="int" />
</composite-id>

<property name="name" column="fld_name" type="string"/>
<property name="description" column="fld_desc" type="string"/>
<property name="colName" column="col_name" type="string"/> <property name="colType" column="col_type" type="java.lang.Character"/>
<property name="tableName" column="tbl_name" type="string"/>
</class>

</hibernate-mapping>





I'm not sure I fully understand the meaning of the <key-many-to-one /> tag. In this table there are two primary keys: fc_id and fld_id. Their combinations look like the following:

fc_id fld_id
1 1
1 2
1 3
2 1
2 2
3 1
3 2
3 3
3 4


Am I mapping this correctly based on this information? And how do composite ids correctly generate new ids on inserts? I would definitely set the fc_id, but the fld_id should just increment. Any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 14, 2004 3:49 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Composite id's are newer generated automatically you have to assign them yourself. But you can create a ComopsiteUserType and use the id tag, additionaly you have to write your own IdGenerator to get automatic id assignment.

Anybody else can help with the <key-many-to-one /> question.

HTH
Ernst


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.