-->
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.  [ 2 posts ] 
Author Message
 Post subject: Repeated column when mapping reflexive association
PostPosted: Mon Apr 21, 2008 4:25 am 
Newbie

Joined: Mon Apr 21, 2008 3:38 am
Posts: 1
Hi all,

I am using Naked Objects framework that generates a mapping file representing a one to many reflexive association (in this very case from class MyClass to itself).

How to avoid the MappingException due to Repeated column in mapping for collection?

Thanks

Hibernate version:
Code:
3.0


Name and version of the database you are using:
Code:
MySQL 5.0.51


Mapping file:

Code:
<?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>
  <class name="org.yourdomainapp.MyClass" table="MYCLASS" lazy="false">
    <id name="id" column="PKmyclassID" type="long" access="org.nakedobjects.nos.store.hibernate.property.OidAccessor">
      <generator class="native"/>
    </id>
    <version name="naked_version" type="long" access="org.nakedobjects.nos.store.hibernate.property.VersionAccessor" column="version"/>
    <property name="naked_modified_by" type="string" access="org.nakedobjects.nos.store.hibernate.property.UserAccessor" column="modified_by"/>
    <property name="naked_modified_on" type="timestamp" access="org.nakedobjects.nos.store.hibernate.property.TimestampAccessor" column="modified_on"/>
    <property name="title" column="title" type="string" access="org.nakedobjects.nos.store.hibernate.property.TitleAccessor"/>
    <bag access="field" name="children" table="MYCLASS_MYCLASS" inverse="true" lazy="false">
      <key column="FKmyclass"/>
      <many-to-many class="org.yourdomainapp.MyClass" column="FKmyclass"/>
    </bag>
    <property type="java.lang.String" name="name" column="name"/>
  </class>
</hibernate-mapping>


Full stack trace of any exception that occurs:

Code:
     [java] 0     [NakedObjectsSystem        main       ERROR]  failed to intialise
     [java] org.hibernate.MappingException: Repeated column in mapping for collection: org.yourdomainapp.MyClass.children column: FKmyclass
     [java]    at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:306)
     [java]    at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:329)
     [java]    at org.hibernate.mapping.Collection.validate(Collection.java:286)
     [java]    at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
     [java]    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
     [java]    at org.nakedobjects.nos.store.hibernate.HibernateUtil.getSessionFactory(HibernateUtil.java:243)
     [java]    at org.nakedobjects.nos.store.hibernate.HibernateUtil.isInitialized(HibernateUtil.java:531)
     [java]    at org.nakedobjects.nos.store.hibernate.HibernateUtil.init(HibernateUtil.java:507)
     [java]    at org.nakedobjects.nos.store.hibernate.HibernateObjectStore.init(HibernateObjectStore.java:393)
     [java]    at org.nakedobjects.nof.persist.objectstore.ObjectStorePersistor.init(ObjectStorePersistor.java:160)
     [java]    at org.nakedobjects.nof.core.persist.ObjectPersistorLogger.init(ObjectPersistorLogger.java:110)
     [java]    at org.nakedobjects.nof.boot.system.NakedObjectsSystem.init(NakedObjectsSystem.java:430)
     [java]    at org.nakedobjects.nof.boot.NakedObjects.run(NakedObjects.java:216)
     [java]    at org.nakedobjects.nof.boot.NakedObjects.main(NakedObjects.java:75)
     [java] Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for collection: org.yourdomainapp.MyClass.children column: FKmyclass
     [java]    at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:306)
     [java]    at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:329)
     [java]    at org.hibernate.mapping.Collection.validate(Collection.java:286)
     [java]    at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
     [java]    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
     [java]    at org.nakedobjects.nos.store.hibernate.HibernateUtil.getSessionFactory(HibernateUtil.java:243)
     [java]    at org.nakedobjects.nos.store.hibernate.HibernateUtil.isInitialized(HibernateUtil.java:531)
     [java]    at org.nakedobjects.nos.store.hibernate.HibernateUtil.init(HibernateUtil.java:507)
     [java]    at org.nakedobjects.nos.store.hibernate.HibernateObjectStore.init(HibernateObjectStore.java:393)
     [java]    at org.nakedobjects.nof.persist.objectstore.ObjectStorePersistor.init(ObjectStorePersistor.java:160)
     [java]    at org.nakedobjects.nof.core.persist.ObjectPersistorLogger.init(ObjectPersistorLogger.java:110)
     [java]    at org.nakedobjects.nof.boot.system.NakedObjectsSystem.init(NakedObjectsSystem.java:430)
     [java]    at org.nakedobjects.nof.boot.NakedObjects.run(NakedObjects.java:216)
     [java]    at org.nakedobjects.nof.boot.NakedObjects.main(NakedObjects.java:75)
     [java] Java Result: 1


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 25, 2008 5:19 am 
Newbie

Joined: Sat Oct 25, 2008 5:16 am
Posts: 1
Since am i facing exaclty the same problem. Do you got any hints solving it?

Regards,

Guido


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