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>