-->
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: Repeated column in mapping should be mapped with insert=&quo
PostPosted: Mon Feb 13, 2006 10:19 am 
Newbie

Joined: Mon Feb 13, 2006 10:09 am
Posts: 2
Hibernate version: 3.1.2

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-access="field" package="Vines" auto-import="false">
<class name ="Person" table="Persons" discriminator-value="Vines.Person" dynamic-update="true" dynamic-insert="true">
<id name="PersonId" type="long" column="PersonId" access="field">
<generator class="increment"/>
</id>

<property name="salutation" column="Salutation" type="java.lang.String"/>
<property name="fName" column="FName" type="java.lang.String"/>
<property name="mName" column="MName" type="java.lang.String"/>
<property name="lName" column="LName" type="java.lang.String"/>
<property name="fatherName" column="FatherName" type="java.lang.String"/>
<property name="occupation" column="Occupation" type="java.lang.String"/>
<property name="bloodGroup" column="BloodGroup" type="java.lang.String"/>


<many-to-one name="correspondenceAddress" column="CorrespondenceAddressId" cascade="all"/>
<many-to-one name="personalAddress" column="PersonalAddressId" cascade="all"/>

</class>
</hibernate-mapping>


Full stack trace of any exception that occurs:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.MappingException: Repeated column in mapping for entity: Person column: AddressId (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:543)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:565)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:583)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:374)
at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:43)
at org.hibernate.cfg.Configuration.validate(Configuration.java:892)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1062)
at MainClass.<clinit>(MainClass.java:35)
java.lang.ExceptionInInitializerError
at MainClass.<clinit>(MainClass.java:43)
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: Person column: AddressId (should be mapped with insert="false" update="false")
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:543)
at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:565)
at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:583)
at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:374)
at org.hibernate.mapping.SingleTableSubclass.validate(SingleTableSubclass.java:43)
at org.hibernate.cfg.Configuration.validate(Configuration.java:892)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1062)
at MainClass.<clinit>(MainClass.java:35)
Exception in thread "main"


Name and version of the database you are using: MSSQL Server 2000


Facing a problem in creating session factory for object that is having the two references of same class. e.g.
class Person {
Address correspondenceAddress;
Address personalAddress;
}

While creating session factory for the above maping file we are facing the above exception.

Please help me out.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 5:03 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Is there something missing from that mapping? I can't see a column "AddressId" once, nevermind twice. Did you edit the mapping while posting it?

Anyway, try being explicit about what class the many-to-ones relate to (class="Address" or whatever). If that doesn't help, post the mapping for Address.


Top
 Profile  
 
 Post subject: OOPs Sorry Its my Fault!!!
PostPosted: Tue Feb 14, 2006 3:39 am 
Newbie

Joined: Mon Feb 13, 2006 10:09 am
Posts: 2
OOPs Sorry Its my Fault!!!

yes u r right, Actually i was writing AddressId for both the columns as column which was creating problem but when i putted original column names from the table problem resolved.
Anyways thanx for the reminding my mistake.


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.