-->
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.  [ 5 posts ] 
Author Message
 Post subject: Repated column in mapping for class
PostPosted: Tue Feb 14, 2006 12:42 am 
Newbie

Joined: Wed Feb 08, 2006 4:10 am
Posts: 16
after run the system i have an error as:
"Repated column in mapping for class Customer.Address should be mapped with insert="false" update="false": ID "

my mapping file for Contact.hbm.xml as:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Customer.Contact, Customer" table="Contact">
<id name="Con_ID" column="ID" type="Int32">
<generator class="identity" />
</id>
<property name="Con_UID" column="UID" type="Guid" />
<property name="Con_Type" column="Type" type="Int32" />
<property name="Con_Contents" column="Contents" type="String(255)" />
<property name="Con_AddressID" column="ContactID" type="Int32" />
<many-to-one name="Con_Addresss" class="Customer.Address, Customer" />
</class>
</hibernate-mapping>

other mapping file which is connected with above was Address.hbm.xml as:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Customer.Address, Customer" table="Address">
<id name="Add_ID" column="ID" type="Int32">
<generator class="identity"></generator>
</id>
<property name="Add_UID" column="UID" type="Guid" />
<property name="Add_Name" column="Name" type="String(50)" />
<property name="Add_Language" column="Language" type="String(50)" />
<property name="Add_Postal" column="Postal" type="String(320)" />
<property name="Add_Address1" column="Address1" type="String(50)" />
<property name="Add_Address2" column="Address2" type="String(50)" />
<property name="Add_Address3" column="Address3" type="String(50)" />
<property name="Add_City" column="City" type="String(50)" />
<property name="Add_Postcode" column="Postcode" type="String(20)" />
<property name="Add_State" column="State" type="String(50)" />
<property name="Add_Country" column="Country" type="String(20)" />
<property name="Add_CustID" column="CustID" type="Int32" />
<set name="Add_Contact" table="Contact" cascade="all">
<key column="ID"/>
<one-to-many class="Customer.Contact, Customer" />
</set>
<many-to-one name="Add_Customers" class="Customer.Customer, Customer" column="ID" />
</class>
</hibernate-mapping>

is there anything wrong with the mapping file,please help.....


Top
 Profile  
 
 Post subject: many-to-one
PostPosted: Tue Feb 14, 2006 1:06 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
I think it has got to do with the way you have mapped the many-to-one relation in the Address class.

Code:
<many-to-one name="Add_Customers" class="Customer.Customer, Customer" column="ID" />


Are you sure it is the column ID and not CustID (ID also seems to be the PK). If it has to be ID then add insert=false, update=false as the exception is suggesting.

You may find this related to the error you are getting:
http://forum.hibernate.org/viewtopic.php?t=952974&highlight=repeated


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 2:26 am 
Newbie

Joined: Wed Feb 08, 2006 4:10 am
Posts: 16
after i have added insert=false and update=false an error as:
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Contact_Address". The conflict occurred in database "D:\NEW FOLDER\SIANG\CUSTOMER\CUSTOMERWEBSITE\APP_DATA\CUSTOMER.MDF", table "dbo.Address", column 'ID'.
The statement has been terminated.


the Address table:
ID->PK
CustID->FK for custamer table

the Contact table:
ID->PK
AddressID->FK for Address table

the Customer table:
ID->PK

means:
customer->Address->Contact

did i put in the correct column at the many-to-one statement?


Top
 Profile  
 
 Post subject: Check
PostPosted: Tue Feb 14, 2006 4:28 am 
Regular
Regular

Joined: Tue Jan 03, 2006 7:21 am
Posts: 85
Did you check the first comment I made....

I think it has got to do with the way you have mapped the many-to-one relation in the Address class.

Code:
<many-to-one name="Add_Customers" class="Customer.Customer, Customer" column="ID" /> 


Are you sure that the column in the above mapping is to be ID and not some other column as CustID.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 4:54 am 
Newbie

Joined: Wed Feb 08, 2006 4:10 am
Posts: 16
thank i have solve it, i just need to add insert=false and update=false with column=CustID into Address.hbm.xml...


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