-->
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: ERR: miltiple FK in the Child table to a single PK in Parent
PostPosted: Wed May 14, 2008 5:39 am 
Newbie

Joined: Wed May 14, 2008 5:15 am
Posts: 3
The parent table :

create table my_batch(
batch_id int identity(1,1) primary key,
batch_name varchar(100) NOT NULL,
created_date datetime DEFAULT GETDATE(),
description varchar(200),
);


Needs to have the BATCH_IDs stored in the child table :

create table batch_batches(
parent_batch_id int,
child_batch_id int,
Foreign Key(parent_batch_id) references cube_batch(batch_id),
Foreign Key(child_batch_id) references cube_batch(batch_id),
);


Where both the PARENT_BATCH_ID and CHILD_BATCH_ID should reference the BATCH_ID which is the PK.

My HBM has:

<class name="com.myApp.hibernate.BatchBatches" table="BATCH_BATCHES" >
<composite-id name="parentBatchId" >
<key-property name="parentBatchId" column="parent_batch" type="integer"/>
<key-many-to-one name="parentBatchId" class="com.myApp.cube.hibernate.CubeBatch" column="batch_id" />
<key-property name="childBatchId" column="batch_id" type="integer"/>
<key-many-to-one name="childBatchId" class="com.myApp.cube.hibernate.MyBatch" column="batch_id" />
</composite-id>
</class>


which gives this Error:

org.hibernate.MappingException: Repeated column in mapping for entity: com.myApp.cube.hib
ernate.BatchBatches column: batch_id (should be mapped with insert="false" update="false")



What could be the best way to map this kind of a double FK- single PK relation?

Please help..!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 5:44 am 
Newbie

Joined: Wed May 14, 2008 5:15 am
Posts: 3
Just a correction, the HMB has this.., rest of the problem is the sam:-

<class name="com.myApp.hibernate.BatchBatches" table="BATCH_BATCHES" >
<composite-id name="parentBatchId" >
<key-property name="parentBatchId" column="parent_batch" type="integer"/>
<key-many-to-one name="parentBatchId" class="com.myApp.cube.hibernate.MyBatch" column="batch_id" />
<key-property name="childBatchId" column="batch_id" type="integer"/>
<key-many-to-one name="childBatchId" class="com.myApp.cube.hibernate.MyBatch" column="batch_id" />
</composite-id>
</class>


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.