-->
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: org.hibernate.MappingException: duplicate import
PostPosted: Wed Nov 09, 2005 12:20 am 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:10 pm
Posts: 30
Not sure what I am doing wrong, but these mapping files were generated by the artifact generation and the the Java source code generated.

Now I wanted to run hbm2java myself, because toStrong(), equals(), and hashCode() were not generated by the artifact generation. I'd like to see if I run hbm2java myself, if those methods will be generated

Here is the ant build file that I run from Eclipse 3.1:

<?xml version="1.0" encoding="utf-8"?>
<project name="mig" default="all" basedir=".">

<property name="src.dir" value="development/src/"/>
<property name="lib.dir" value="development/lib/"/>
<property name="hibernatetoolslib.dir" value="/opt/eclipse/plugins/org.hibernate.eclipse_3.1.0.beta1/lib/tools/"/>

<taskdef
name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask">
<classpath>
<pathelement location="${hibernatetoolslib.dir}/hibernate-tools.jar"/>
<pathelement location="${hibernatetoolslib.dir}/velocity-1.4.jar"/>
<pathelement location="${hibernatetoolslib.dir}/jtidy-r8-21122004.jar"/>
<pathelement location="${hibernatetoolslib.dir}/velocity-tools-generic-1.4.jar"/>
<pathelement location="${lib.dir}/hibernate3.jar"/>
<pathelement location="${lib.dir}/jconn2.jar"/>
<pathelement location="${lib.dir}/commons-logging.jar"/>
<pathelement location="${lib.dir}/dom4j-1.6.jar"/>
</classpath>
</taskdef>

<hibernatetool destdir="[output dir]">
<classpath>
<path location="${src.dir}"/>
</classpath>

<configuration configurationfile="hibernate-test.cfg.xml" >
<fileset dir="${src.dir}"> <!-- A configuration can take a configurationfile and/or a fileset of hbm.xml's -->
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>

<hbm2java/> <!-- generate default .java files -->
</hibernatetool>
</project>


Hibernate version:

Hibernate 3.0
HibernateTools 3.1 beta
Eclipse 3.1
JDK 1.4.2

Mapping documents:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.mig.provisioning.db.hibernate.Campaign" table="campaign">
<id name="campaignId" type="integer">
<column name="campaign_id" />
<generator class="native" />
</id>
<many-to-one name="client" class="com.mig.provisioning.db.hibernate.Client" fetch="select">
<column name="client_id" not-null="true" />
</many-to-one>
<many-to-one name="numberRegister" class="com.mig.provisioning.db.hibernate.NumberRegister" fetch="select">
<column name="number_register_id" not-null="true" />
</many-to-one>
<property name="name" type="string">
<column name="name" not-null="true" />
</property>
<property name="moRate" type="long">
<column name="mo_rate" precision="18" scale="0" not-null="true" />
</property>
<property name="mtRate" type="long">
<column name="mt_rate" precision="18" scale="0" not-null="true" />
</property>
<property name="countryCode" type="string">
<column name="country_code" length="2" not-null="true" />
</property>
<property name="prestartDate" type="timestamp">
<column name="prestart_date" length="23" not-null="true" />
</property>
<property name="startDate" type="timestamp">
<column name="start_date" length="23" not-null="true" />
</property>
<property name="endDate" type="timestamp">
<column name="end_date" length="23" />
</property>
<set name="campaignTemplates" inverse="true">
<key>
<column name="campaign_id" not-null="true" />
</key>
<one-to-many class="com.mig.provisioning.db.hibernate.CampaignTemplate" />
</set>
<set name="provisioningRequests" inverse="true">
<key>
<column name="campaign_id" not-null="true" />
</key>
<one-to-many class="com.mig.provisioning.db.hibernate.ProvisioningRequest" />
</set>
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Buildfile: /home/jsalvo/workspace/softgame-latest/build-hibernate.xml
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] 9/11/2005 15:11:16 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.0.5
[hibernatetool] 9/11/2005 15:11:16 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] 9/11/2005 15:11:16 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using CGLIB reflection optimizer
[hibernatetool] 9/11/2005 15:11:16 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 9/11/2005 15:11:16 org.hibernate.cfg.Configuration configure
[hibernatetool] INFO: configuring from file: hibernate-test.cfg.xml
[hibernatetool] 9/11/2005 15:11:17 org.hibernate.cfg.Configuration doConfigure
[hibernatetool] INFO: Configured SessionFactory: Hibernate-SybaseTest
[hibernatetool] 9/11/2005 15:11:18 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/GeneralHbmSettings.hbm.xml
[hibernatetool] 9/11/2005 15:11:18 org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Mapping file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/Campaign.hbm.xml
[hibernatetool] 9/11/2005 15:11:18 org.hibernate.cfg.Configuration add
[hibernatetool] SEVERE: Could not compile the mapping document
[hibernatetool] org.hibernate.MappingException: duplicate import: com.mig.provisioning.db.hibernate.Campaign
[hibernatetool] at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
[hibernatetool] at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
[hibernatetool] at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
[hibernatetool] at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
[hibernatetool] at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
[hibernatetool] at org.hibernate.cfg.Configuration.add(Configuration.java:362)
[hibernatetool] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
[hibernatetool] at org.hibernate.cfg.Configuration.addFile(Configuration.java:245)
[hibernatetool] at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:140)
[hibernatetool] at org.hibernate.tool.ant.ConfigurationTask.addMappings(ConfigurationTask.java:123)
[hibernatetool] at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:109)
[hibernatetool] at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:180)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:196)
[hibernatetool] at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:90)
[hibernatetool] at org.hibernate.tool.ant.Hbm2JavaGeneratorTask.configureExporter(Hbm2JavaGeneratorTask.java:37)
[hibernatetool] at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:38)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:144)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.parseBuildFile(InternalAntRunner.java:191)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:400)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
[hibernatetool] 9/11/2005 15:11:18 org.hibernate.cfg.Configuration addFile
[hibernatetool] SEVERE: Could not configure datastore from file: /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/Campaign.hbm.xml
[hibernatetool] org.hibernate.MappingException: duplicate import: com.mig.provisioning.db.hibernate.Campaign
[hibernatetool] at org.hibernate.cfg.Mappings.addImport(Mappings.java:105)
[hibernatetool] at org.hibernate.cfg.HbmBinder.bindPersistentClassCommonValues(HbmBinder.java:541)
[hibernatetool] at org.hibernate.cfg.HbmBinder.bindClass(HbmBinder.java:488)
[hibernatetool] at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:234)
[hibernatetool] at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:152)
[hibernatetool] at org.hibernate.cfg.Configuration.add(Configuration.java:362)
[hibernatetool] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:400)
[hibernatetool] at org.hibernate.cfg.Configuration.addFile(Configuration.java:245)
[hibernatetool] at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:140)
[hibernatetool] at org.hibernate.tool.ant.ConfigurationTask.addMappings(ConfigurationTask.java:123)
[hibernatetool] at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:109)
[hibernatetool] at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:180)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:196)
[hibernatetool] at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:90)
[hibernatetool] at org.hibernate.tool.ant.Hbm2JavaGeneratorTask.configureExporter(Hbm2JavaGeneratorTask.java:37)
[hibernatetool] at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:38)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:144)
[hibernatetool] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[hibernatetool] at org.apache.tools.ant.Task.perform(Task.java:364)
[hibernatetool] at org.apache.tools.ant.Target.execute(Target.java:341)
[hibernatetool] at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:142)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.parseBuildFile(InternalAntRunner.java:191)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:400)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

BUILD FAILED
/home/jsalvo/workspace/softgame-latest/build-hibernate.xml:23: Failed in building configuration when adding /home/jsalvo/workspace/softgame-latest/development/src/com/mig/provisioning/db/hibernate/Campaign.hbm.xml

Total time: 2 seconds


Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 12:57 am 
Beginner
Beginner

Joined: Mon Nov 07, 2005 11:10 pm
Posts: 30
Never mind .... I found the mapping.xml file generated by the artifact generator that has the imports. Deleted that file


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.