-->
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.  [ 7 posts ] 
Author Message
 Post subject: MappingException: Repeated column in mapping for collection
PostPosted: Wed Sep 10, 2003 5:34 pm 
Beginner
Beginner

Joined: Wed Sep 10, 2003 5:32 pm
Posts: 28
Hi everyone,

I got the following error at hibernate version 2.0.3 and I have no idea what does it mean??

net.sf.hibernate.MappingException: Repeated column in mapping for collection: com.accucast4.testcase5.Customer.recipients column: RC_C_ID
at net.sf.hibernate.collection.CollectionPersister.checkColumnDuplication(CollectionPersister.java:838)
at net.sf.hibernate.collection.CollectionPersister.<init>(CollectionPersister.java:214)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:627)
at com.accucast4.customerdatasource.CustomerDataSourceConfigurationFactory.addSessionManagementHolder(CustomerDataSourceConfigurationFactory.java:62)
at com.accucast4.customerdatasource.CustomerDataSourceConfigurationFactory.retrieveDataSourceCfgHolder(CustomerDataSourceConfigurationFactory.java:85)
at com.accucast4.customerdatasource.CustomerDataSourceConfigurationFactory.getSession(CustomerDataSourceConfigurationFactory.java:107)
at com.accucast3.kernel.test.TestCustomerDataSourceConfiguration.getSession(TestCustomerDataSourceConfiguration.java:32)
at com.accucast3.kernel.Kernel.getSession(Kernel.java:62)
at com.accucast3.kernel.Kernel.main(Kernel.java:75)


Does anyone have any idea?? I have tried this mapping in version 2.0.2 and I have no problem on using it.

Here is the customer mapping file:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>

<class
name="com.accucast4.testcase5.Customer"
table="CUSTOMER"
>
<id
name="custId"
type="long"
column="CUST_ID"
>
<generator class="assigned" />
</id>
<property
name="firstName"
type="java.lang.String"
column="FIRST_NAME"
length="20"
/>

<!-- bi-directional one-to-many association to Recipient -->
<map
name="recipients"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="RC_C_ID" />
</key>
<composite-index class="com.accucast4.testcase5.RecipientPK">
<key-property name="rcDId" type="long" column="RC_D_ID" />
<key-property name="rcCId" type="long" column="RC_C_ID" />
</composite-index>
<one-to-many
class="com.accucast4.testcase5.Recipient"
/>
</map>
</class>
</hibernate-mapping>

Thanks..

Vivian Fonger


Top
 Profile  
 
 Post subject: duplicate column mapped as key and index
PostPosted: Wed Sep 10, 2003 7:54 pm 
Senior
Senior

Joined: Sun Aug 31, 2003 3:14 pm
Posts: 151
Location: Earth (at the moment)
Column RC_C_ID is repeated, first as
Quote:
<key>
<column name="RC_C_ID" />
</key>

and then right afterwards as part of a composite-index
Quote:
<key-property name="rcCId" type="long" column="RC_C_ID" />


I'm not an expert by any means but I think the <key> and <index> tags work together for a composite foreign key if that is what you are trying to do.


Top
 Profile  
 
 Post subject: oops!
PostPosted: Wed Sep 10, 2003 7:56 pm 
Senior
Senior

Joined: Sun Aug 31, 2003 3:14 pm
Posts: 151
Location: Earth (at the moment)
Quote:
I think the <key> and <index> tags work together for a composite foreign key


Oops! Sorry, I take that back, I was thinking about foreign keys while I was writing.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 10, 2003 11:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Duplication of columns b/w the <key> and <index> is not supported (it has never been supported, actually ... it just happened to "work" on certain databases.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2003 9:52 am 
Beginner
Beginner

Joined: Wed Sep 10, 2003 5:32 pm
Posts: 28
If <key> and <index> is not supported, how should I represent the relationship between Customer and Recipient?? Recipient has a foreign key to customer (RC_C_ID) and the primary key is a composite key (RC_D_ID, RC_C_ID) and I want to use MAP instead of SET. How should I map customer and recipient??


Top
 Profile  
 
 Post subject: just index
PostPosted: Thu Sep 11, 2003 11:07 am 
Senior
Senior

Joined: Sun Aug 31, 2003 3:14 pm
Posts: 151
Location: Earth (at the moment)
Quote:
If <key> and <index> is not supported


It is supported, just not with duplicate columns, you can not use the same column for both the key and the index.

Quote:
how should I represent the relationship between Customer and Recipient?? Recipient has a foreign key to customer (RC_C_ID) and the primary key is a composite key (RC_D_ID, RC_C_ID) and I want to use MAP instead of SET. How should I map customer and recipient??


You should be able to use just RC_D_ID as the index.

If I understand correctly, each customer has a Map of recipients in which case the <key> tag on RC_C_ID would narrow down the recipients to just the ones with that customer ID and then you can index them by their ID which I am guessing is the RC_D_ID?

Let me know if that is not what you are trying to do.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2003 2:25 pm 
Beginner
Beginner

Joined: Wed Sep 10, 2003 5:32 pm
Posts: 28
It works.. Thanks


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