-->
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: Mapping problem with several foreign keys
PostPosted: Wed May 26, 2004 3:06 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
I have a mapping problem. I run my main program and Hibernate throws a MappingException. When I print it, it looks like this:

ERROR = net.sf.hibernate.MappingException: Repeated column in mapping for class net.sf.hibernate.CustomerorderT should be mapped with insert="false" update="false": COUNTRYCODE


Now, According to documentation section 8.2 Limitations
(http://www.hibernate.org/hib_docs/reference/en/html_single/#inheritance-limitations) it says that:

Quote:
Hibernate assumes that an association maps to exactly one foreign key column. Multiple associations per foreign key are tolerated (you might need to specify inverse="true" or insert="false" update="false"), but there is no way to map any association to multiple foreign keys.


Apperantly I have more then one column that it maps to and I use the inverse="true" but that didn't give me any help.

Anyone knows what the problem can be and how to solve it? Check out my xml file and the code around the red section. I think that's where the problem is but I can't get my finger on it.


CustomerorderT.hbm.xml
-----------------------------

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

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin

http://boss.bekk.no/boss/middlegen/
http://hibernate.sourceforge.net/
-->

<class
name="net.sf.hibernate.CustomerorderT"
table="CUSTOMERORDER_T"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="CUSTOMERORDER_T"
</meta>

<composite-id>
<meta attribute="class-description" inherit="false">
@hibernate.id
generator-class="assigned"
</meta>
<key-property
name="customerorderno"
column="CUSTOMERORDERNO"
type="java.lang.String"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="CUSTOMERORDERNO"
length="10"
</meta>
</key-property>
<!-- bi-directional many-to-one association to CountryT -->
<key-many-to-one
name="countryT"
class="net.sf.hibernate.CountryT"
>
<meta attribute="field-description">
@hibernate.many-to-one
column="COUNTRYCODE""
</meta>
<column name="COUNTRYCODE" />
</key-many-to-one>
</composite-id>

<property
name="createdate"
type="java.sql.Timestamp"
column="CREATEDATE"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="CREATEDATE"
length="7"
</meta>
</property>
<property
name="deliverydate"
type="java.sql.Timestamp"
column="DELIVERYDATE"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="DELIVERYDATE"
length="7"
</meta>
</property>
<property
name="price"
type="java.math.BigDecimal"
column="PRICE"
length="14"
>
<meta attribute="field-description">
@hibernate.property
column="PRICE"
length="14"
</meta>
</property>
<property
name="freightcost"
type="java.math.BigDecimal"
column="FREIGHTCOST"
length="14"
>
<meta attribute="field-description">
@hibernate.property
column="FREIGHTCOST"
length="14"
</meta>
</property>
<property
name="status"
type="java.lang.String"
column="STATUS"
length="2"
>
<meta attribute="field-description">
@hibernate.property
column="STATUS"
length="2"
</meta>
</property>
<property
name="paymentmode"
type="java.lang.String"
column="PAYMENTMODE"
length="2"
>
<meta attribute="field-description">
@hibernate.property
column="PAYMENTMODE"
length="2"
</meta>
</property>
<property
name="totalvolume"
type="java.math.BigDecimal"
column="TOTALVOLUME"
length="8"
>
<meta attribute="field-description">
@hibernate.property
column="TOTALVOLUME"
length="8"
</meta>
</property>
<property
name="totalweight"
type="java.math.BigDecimal"
column="TOTALWEIGHT"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="TOTALWEIGHT"
length="7"
</meta>
</property>
<property
name="totalcost"
type="java.math.BigDecimal"
column="TOTALCOST"
length="14"
>
<meta attribute="field-description">
@hibernate.property
column="TOTALCOST"
length="14"
</meta>
</property>
<property
name="versionno"
type="java.lang.Integer"
column="VERSIONNO"
length="2"
>
<meta attribute="field-description">
@hibernate.property
column="VERSIONNO"
length="2"
</meta>
</property>

<!-- associations -->
<!-- bi-directional many-to-one association to CustomerT -->
<many-to-one
name="customerT"
class="net.sf.hibernate.CustomerT"
not-null="true"
>
<meta attribute="field-description">
@hibernate.many-to-one
not-null="true"
@hibernate.column name="COUNTRYCODE"
@hibernate.column name="CUSTOMERNO"
</meta>

<column name="COUNTRYCODE" />
<column name="CUSTOMERNO" />
</many-to-one>
<!-- bi-directional one-to-many association to CustomerorderlineT -->
<set
name="customerorderlineTs"
lazy="true"
inverse="true"
>
<meta attribute="field-description" >
@hibernate.set
lazy="true"
inverse="true"

@hibernate.collection-key
column="COUNTRYCODE"
@hibernate.collection-key
column="CUSTOMERORDERNO"

@hibernate.collection-one-to-many
class="net.sf.hibernate.CustomerorderlineT"
</meta>

<key>
<column name="COUNTRYCODE" />
<column name="CUSTOMERORDERNO" />
</key>
<one-to-many
class="net.sf.hibernate.CustomerorderlineT"
/>
</set>
<!-- bi-directional one-to-one association to DeliveryaddressT -->
<one-to-one
name="deliveryaddressT"
class="net.sf.hibernate.DeliveryaddressT"
outer-join="auto"
>
<meta attribute="field-description">
@hibernate.one-to-one
outer-join="auto"
</meta>
</one-to-one>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 26, 2004 4:35 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Nobody got any idea that can help me??


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 31, 2004 1:03 am 
Newbie

Joined: Wed Apr 07, 2004 2:49 am
Posts: 5
Hi there , I am also getting the same error. Did you solve your problem

Razi


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 01, 2004 4:06 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
no link witrh inverse="true"
Check in one mapping file each column name. There should not be any dupe.
If true, the put insert="true" update="true" on the other properties

_________________
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.