Hey,
I have a mapping problem and my toString method prints out the exception:
Code:
Funkar ej. ERROR = net.sf.hibernate.MappingException: Repeated column in mapping for class net.sf.hibernate.CustomerorderT should be mapped with insert="false" update="false": COUNTRYCODE
Below I got the xml and java file for CustomerorderT. I've tried to insert the
insert="false" update="false" but didn't work.
Has anyone got any idea how to solve it?
Br. Newman
CustomerorderT.hbm.xml
------------------------------
Code:
<?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" /> Code:
</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>Code:
<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>
CustomerorderT.java
-------------------------
Code:
package net.sf.hibernate;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* @hibernate.class
* table="CUSTOMERORDER_T"
*
*/
public class CustomerorderT implements Serializable {
/** identifier field */
private String customerorderno;
/** nullable persistent field */
private Date createdate;
/** nullable persistent field */
private Date deliverydate;
/** nullable persistent field */
private BigDecimal price;
/** nullable persistent field */
private BigDecimal freightcost;
/** nullable persistent field */
private String status;
/** nullable persistent field */
private String paymentmode;
/** nullable persistent field */
private BigDecimal totalvolume;
/** nullable persistent field */
private BigDecimal totalweight;
/** nullable persistent field */
private BigDecimal totalcost;
/** nullable persistent field */
private Integer versionno;
/** nullable persistent field */
private DeliveryaddressT deliveryaddressT;
/** identifier field */
private CountryT countryT;
/** persistent field */
private CustomerT customerT;
/** persistent field */
private Set customerorderlineTs;
/** full constructor */
public CustomerorderT(String customerorderno, Date createdate, Date deliverydate, BigDecimal price, BigDecimal freightcost, String status, String paymentmode, BigDecimal totalvolume, BigDecimal totalweight, BigDecimal totalcost, Integer versionno, DeliveryaddressT deliveryaddressT, CountryT countryT, CustomerT customerT, Set customerorderlineTs) {
this.customerorderno = customerorderno;
this.createdate = createdate;
this.deliverydate = deliverydate;
this.price = price;
this.freightcost = freightcost;
this.status = status;
this.paymentmode = paymentmode;
this.totalvolume = totalvolume;
this.totalweight = totalweight;
this.totalcost = totalcost;
this.versionno = versionno;
this.deliveryaddressT = deliveryaddressT;
this.countryT = countryT;
this.customerT = customerT;
this.customerorderlineTs = customerorderlineTs;
}
/** default constructor */
public CustomerorderT() {
}
/** minimal constructor */
public CustomerorderT(String customerorderno, CountryT countryT, CustomerT customerT, Set customerorderlineTs) {
this.customerorderno = customerorderno;
this.countryT = countryT;
this.customerT = customerT;
this.customerorderlineTs = customerorderlineTs;
}
/**
* @hibernate.property
* column="CUSTOMERORDERNO"
* length="10"
*
*/
public String getCustomerorderno() {
return this.customerorderno;
}
public void setCustomerorderno(String customerorderno) {
this.customerorderno = customerorderno;
}
/**
* @hibernate.property
* column="CREATEDATE"
* length="7"
*
*/
public Date getCreatedate() {
return this.createdate;
}
public void setCreatedate(Date createdate) {
this.createdate = createdate;
}
/**
* @hibernate.property
* column="DELIVERYDATE"
* length="7"
*
*/
public Date getDeliverydate() {
return this.deliverydate;
}
public void setDeliverydate(Date deliverydate) {
this.deliverydate = deliverydate;
}
/**
* @hibernate.property
* column="PRICE"
* length="14"
*
*/
public BigDecimal getPrice() {
return this.price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
/**
* @hibernate.property
* column="FREIGHTCOST"
* length="14"
*
*/
public BigDecimal getFreightcost() {
return this.freightcost;
}
public void setFreightcost(BigDecimal freightcost) {
this.freightcost = freightcost;
}
/**
* @hibernate.property
* column="STATUS"
* length="2"
*
*/
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
/**
* @hibernate.property
* column="PAYMENTMODE"
* length="2"
*
*/
public String getPaymentmode() {
return this.paymentmode;
}
public void setPaymentmode(String paymentmode) {
this.paymentmode = paymentmode;
}
/**
* @hibernate.property
* column="TOTALVOLUME"
* length="8"
*
*/
public BigDecimal getTotalvolume() {
return this.totalvolume;
}
public void setTotalvolume(BigDecimal totalvolume) {
this.totalvolume = totalvolume;
}
/**
* @hibernate.property
* column="TOTALWEIGHT"
* length="7"
*
*/
public BigDecimal getTotalweight() {
return this.totalweight;
}
public void setTotalweight(BigDecimal totalweight) {
this.totalweight = totalweight;
}
/**
* @hibernate.property
* column="TOTALCOST"
* length="14"
*
*/
public BigDecimal getTotalcost() {
return this.totalcost;
}
public void setTotalcost(BigDecimal totalcost) {
this.totalcost = totalcost;
}
/**
* @hibernate.property
* column="VERSIONNO"
* length="2"
*
*/
public Integer getVersionno() {
return this.versionno;
}
public void setVersionno(Integer versionno) {
this.versionno = versionno;
}
/**
* @hibernate.one-to-one
* outer-join="auto"
*
*/
public DeliveryaddressT getDeliveryaddressT() {
return this.deliveryaddressT;
}
public void setDeliveryaddressT(DeliveryaddressT deliveryaddressT) {
this.deliveryaddressT = deliveryaddressT;
}
/**
* @hibernate.many-to-one
* column="COUNTRYCODE""
*
*/
public CountryT getCountryT() {
return this.countryT;
}
public void setCountryT(CountryT countryT) {
this.countryT = countryT;
}
/**
* @hibernate.many-to-one
* not-null="true"
* @hibernate.column name="COUNTRYCODE"
* @hibernate.column name="CUSTOMERNO"
*
*/
public CustomerT getCustomerT() {
return this.customerT;
}
public void setCustomerT(CustomerT customerT) {
this.customerT = customerT;
}
/**
* @hibernate.set
* lazy="true"
* inverse="true"
* @hibernate.collection-key
* column="COUNTRYCODE"
* @hibernate.collection-key
* column="CUSTOMERORDERNO"
* @hibernate.collection-one-to-many
* class="CustomerorderlineT"
*
*/
public Set getCustomerorderlineTs() {
return this.customerorderlineTs;
}
public void setCustomerorderlineTs(Set customerorderlineTs) {
this.customerorderlineTs = customerorderlineTs;
}
public String toString() {
return new ToStringBuilder(this)
.append("customerorderno", getCustomerorderno())
.append("countryT", getCountryT())
.toString();
}
public boolean equals(Object other) {
if ( !(other instanceof CustomerorderT) ) return false;
CustomerorderT castOther = (CustomerorderT) other;
return new EqualsBuilder()
.append(this.getCustomerorderno(), castOther.getCustomerorderno())
.append(this.getCountryT(), castOther.getCountryT())
.isEquals();
}
public int hashCode() {
return new HashCodeBuilder()
.append(getCustomerorderno())
.append(getCountryT())
.toHashCode();
}
}