-->
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.  [ 4 posts ] 
Author Message
 Post subject: Exception: Repeated column in mapping for collection
PostPosted: Fri Nov 28, 2003 12:29 pm 
Newbie

Joined: Fri Nov 28, 2003 11:34 am
Posts: 2
Location: Moscow, Russia
I have pretty simple schema:

CREATE TABLE Customer (
customer_id INTEGER NOT NULL,
name VARCHAR(100) NOT NULL,
...
);

CREATE TABLE Attribute (
attribute_id INTEGER NOT NULL,
name VARCHAR(50) NOT NULL,
description VARCHAR(255) NOT NULL,
...
);

CREATE TABLE Customer_Attribute (
customer_id INTEGER NOT NULL,
value FLOAT NULL,
score FLOAT NULL,
attribute_id INTEGER NOT NULL
);

Hibernate mapping looks like this:

<class name="com.pa.pharma.customer.Customer" table="CUSTOMER" dynamic-update="true" >
<id column="CUSTOMER_ID" name="id" type="long">
<generator class="native"/>
</id>

<property column="NAME" length="100" name="name" not-null="true" type="string"/>
<map name="attributes" table="customer_attribute" lazy="true" >
<key column="customer_id" />
<index column="attribute_id" type="long" />
<composite-element class="com.pa.pharma.segmentation.CustomerAttribute" >
<property name="score" column="SCORE" type="double" />
<property name="value" column="VALUE" type="double" />
<many-to-one name="attribute" class="com.pa.pharma.segmentation.Attribute"
column="attribute_id" outer-join="true" update="false" insert="false" />
</composite-element>
</map>
</class>

After installing Hibernate 2.0.3 I've got an exception:
net.sf.hibernate.MappingException: Repeated column in mapping for
collection: com.pa.pharma.customer.Customer.attributes column:
attribute_id

Previous versions 2.0.1 and 2.0.2 works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 28, 2003 1:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This is weird to have the index of a collection (attribute_id) which is also the FK to a many to one.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 4:33 am 
Newbie

Joined: Fri Nov 28, 2003 11:34 am
Posts: 2
Location: Moscow, Russia
epbernard wrote:
This is weird to have the index of a collection (attribute_id) which is also the FK to a many to one.

Actually my intention was to create mapping similar to this http://www.hibernate.org/118.html#A10, but instead of set use map in order to have an ability to lookup attribute value by attribute id. What was wrong in my approach?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 10, 2003 11:14 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Have a look at the doco and the behavior of the index attribute. It's related to index of collection, not pk or fk at all.

_________________
Emmanuel


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