-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with mapping after generated with middlegen
PostPosted: Wed May 26, 2004 3:48 am 
Regular
Regular

Joined: Tue May 11, 2004 9:23 am
Posts: 69
Hey,

I have run my hiberante code in middlegen and now I got 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.


Br. Newman

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: Wed May 26, 2004 8:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You have CountryCode mapped twice, eg, In composite Key and in a One-to-Many composite relationship. This is overlap between key and non-key (foreign key) relationships. Not all possible composite key relationship combinations can be mapped. Hibernate does a good job of dealing with composite keys but the offical line is to not use composite keys if at possible.


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