-->
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: Duplicate import exception when using hbm2ddl
PostPosted: Mon Sep 27, 2004 8:06 am 
Newbie

Joined: Mon Sep 27, 2004 7:29 am
Posts: 1
Location: Groningen
I'm trying to make a ddl of a mapping file (see mapping documents). It's a fairly simple mapping file containing subclass mappings and an id. I have isolated to the following classes (see section : Java files involved in the mapping) and mapping file (see mapping documents). I get the following error:
Could not compile the mapping document
[schemaexport] net.sf.hibernate.MappingException: duplicate import: AbstractSpil
(see section : Full stack trace of any exception that occurs)

I haven't got a clue what that means, when I use the same strategy on an other class hierarchy everthing goes fine. I've also searched if the table name or class name is beeing used in an other mapping file but this is not the case. I've removed all the other mapping files and java files so only the AbstractSpil and its subclasses are beeing mapped. Any ideas anyone?

Hibernate version: 2.1

Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM
         "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<!--

-->
<hibernate-mapping package="com.fnv.trappenCalc.domeinModel" >

<class name="AbstractSpil"
      table="SPILLEN_SPIL"
      lazy="false">

   <!-- Common id property. -->
   <id name="key"
      type="long"
      column="SPIL_KEY"
      unsaved-value="null"
      access="field">
      <generator class="native"/>
   </id>

    <discriminator column="SPIL_TYPE" type="string" />

    <subclass name="GedraaideSpil" discriminator-value = "GedraaideSpil">
    </subclass>

   <subclass name="KantigeSpil" discriminator-value = "KantigeSpil">
        <property name="aantalGroefjes"
            type="int"
            column="AANTAL_GROEFJES"
            access="field"
            not-null="false"/>

        <property name="aantalGroefjesFasset"
            type="int"
            column="AANTAL_GROEFJES_FASSET"
            access="field"
            not-null="false"/>
    </subclass>
</class>


Full stack trace of any exception that occurs:
Code:
[schemaexport] 13:03:43,138 ERROR Configuration:255 - Could not compile the mapp
ing document
[schemaexport] net.sf.hibernate.MappingException: duplicate import: AbstractSpil

[schemaexport]  at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
[schemaexport]  at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
[schemaexport]  at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
[schemaexport]  at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
[schemaexport]  at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252
)
[schemaexport]  at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java
:174)
[schemaexport]  at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfigurati
on(SchemaExportTask.java:195)
[schemaexport]  at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(Schema
ExportTask.java:135)
[schemaexport]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:275)
[schemaexport]  at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport]  at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport]  at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport]  at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

[schemaexport]  at org.apache.tools.ant.Project.executeTargets(Project.java:1062
)
[schemaexport]  at org.apache.tools.ant.Main.runBuild(Main.java:673)
[schemaexport]  at org.apache.tools.ant.Main.startAnt(Main.java:188)
[schemaexport]  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[schemaexport]  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
[schemaexport] 13:03:43,154 ERROR Configuration:178 - Could not configure datast
ore from file: D:\programmeren\werk\TrappenNieuw\classes\com\fnv\trappenCalc\dom
einModel\AbstractSpil.hbm.xml
[schemaexport] net.sf.hibernate.MappingException: duplicate import: AbstractSpil

[schemaexport]  at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
[schemaexport]  at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
[schemaexport]  at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
[schemaexport]  at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
[schemaexport]  at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252
)
[schemaexport]  at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java
:174)
[schemaexport]  at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfigurati
on(SchemaExportTask.java:195)
[schemaexport]  at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(Schema
ExportTask.java:135)
[schemaexport]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:275)
[schemaexport]  at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport]  at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport]  at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport]  at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

[schemaexport]  at org.apache.tools.ant.Project.executeTargets(Project.java:1062
)
[schemaexport]  at org.apache.tools.ant.Main.runBuild(Main.java:673)
[schemaexport]  at org.apache.tools.ant.Main.startAnt(Main.java:188)
[schemaexport]  at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[schemaexport]  at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

BUILD FAILED
D:\programmeren\werk\TrappenNieuw\build.xml:150: Schema text failed: net.sf.hibe
rnate.MappingException: duplicate import: AbstractSpil
        at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTa
sk.java:146)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
        at org.apache.tools.ant.Main.runBuild(Main.java:673)
        at org.apache.tools.ant.Main.startAnt(Main.java:188)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Caused by: net.sf.hibernate.MappingException: net.sf.hibernate.MappingException:
duplicate import: AbstractSpil
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:179)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(Schem
aExportTask.java:195)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTa
sk.java:135)
        ... 10 more
Caused by: net.sf.hibernate.MappingException: duplicate import: AbstractSpil
        at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
        at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:174)
        ... 12 more
--- Nested Exception ---
net.sf.hibernate.MappingException: net.sf.hibernate.MappingException: duplicate
import: AbstractSpil
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:179)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(Schem
aExportTask.java:195)
        at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTa
sk.java:135)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
        at org.apache.tools.ant.Main.runBuild(Main.java:673)
        at org.apache.tools.ant.Main.startAnt(Main.java:188)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
Caused by: net.sf.hibernate.MappingException: duplicate import: AbstractSpil
        at net.sf.hibernate.cfg.Mappings.addImport(Mappings.java:85)
        at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:126)
        at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:221)
        at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1256)
        at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252)
        at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java:174)
        ... 12 more



Name and version of the database you are using: mySql 4.0.20a

Java files involved in the mapping:
Code:
package com.fnv.trappenCalc.domeinModel;

class IdentityModelImpl implements IdentityModel, Comparable
{
    protected int version;
    protected Long key;

    public Long getKey()
    {
        return this.key;
    }

    public boolean equals(Object o)
    {
        if (o instanceof IdentityModelImpl)
        {
            IdentityModelImpl other = (IdentityModelImpl) o;

            if (this.key == other.key)
                return true;

            if (this.key != null)
                return this.key.equals(other.key);
        }
        return false;
    }

    public int hashCode()
    {
        return this.key.hashCode();
    }

    public int compareTo(Object o)
    {
        if (!(o instanceof IdentityModelImpl))
            return -1;

        IdentityModelImpl other = (IdentityModelImpl) o;
        if (this.key == null)
            return -1;

        return this.key.compareTo(other.key);
    }

    public Model copy()
    {
        return null;
    }
}


Code:
package com.fnv.trappenCalc.domeinModel;

import com.fnv.util.dimension.Dimension3D;
import com.fnv.trappenCalc.domeinModel.IdentityModelImpl;

abstract public class AbstractSpil extends IdentityModelImpl
        implements Spil
{
    //these 2 properties are not beeing mapped at the time of the error to   
    //keep things simple
    private Dimension3D afmeting;
    private SpilToevoegingTypeImpl spilToevoeging;

    protected AbstractSpil() {}

}


Code:
package com.fnv.trappenCalc.domeinModel;

public class KantigeSpil extends AbstractSpil
{
    private int aantalGroefjes;
    private int aantalGroefjesFasset;

    private KantigeSpil() {}
}


Code:
package com.fnv.trappenCalc.domeinModel;

public class GedraaideSpil extends AbstractSpil
{
    private GedraaideSpil() {}
}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 01, 2004 5:49 pm 
Newbie

Joined: Fri Oct 22, 2004 5:12 pm
Posts: 1
I had a similar problem. It was caused by an error in my Ant script. The code below shows the call to the SchemaExport.

Code:
<schemaexport
     config="${project.path}/hibernate.cfg.xml"
     quiet="no"
     text="yes"
     drop="no"
     delimiter=";"
     output="create-tables.sql">
     <fileset dir="${project.path}" includes="**/*.hbm.xml"/>
</schemaexport>


As I already referenced the concerned .hbm.xml file in my hibernate.cfg.xml it got referenced a second time by the fileset. Removing the fileset solved the problem:

Code:
<schemaexport
     config="${project.path}/hibernate.cfg.xml"
     quiet="no"
     text="yes"
     drop="no"
     delimiter=";"
     output="create-tables.sql">
</schemaexport>


Greetings

Andre


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.