-->
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: DuplicateMappingException when using hbm2java exporter
PostPosted: Sun Jun 25, 2006 9:39 am 
Newbie

Joined: Mon Nov 28, 2005 10:09 am
Posts: 11
I'm trying to run an hbm2java ant task. But I got an exception(DuplicateMappingException)

build.xml :
-------------------------------------------------
<?xml version="1.0"?>
<project name="helloWorld" basedir="src" default="pojo">
<property name="src.dir" value="."/>
<property name="build.dir" value="."/>
<property name="jdbc.driver.jar" value="C:/Program Files/Microsoft SQL Server 2000 Driver for JDBC/lib/*.*"/>
<property name="code.java.dir" value="D:/code.java"/>
<property name="hbmtools.dir" value="${code.java.dir}/hibernate-tools/lib/tools"/>
<property name="hbm.dir" value="${code.java.dir}/hibernate-3.2"/>

<path id="toolslib">
<path location="."/>
<path location="${src.dir}"/>
<path location="${build.dir}"/>
<path location="${code.java.dir}/hibernate-3.2/hibernate3.jar"/>
<path location="${hbmtools.dir}/hibernate-tools.jar"/>
<path location="${hbmtools.dir}/freemarker.jar"/>
<path location="${hbmtools.dir}/jtidy-r8-21122004.jar"/>
<path location="${hbm.dir}/lib/dom4j-1.6.1.jar"/>
<path location="${hbm.dir}/lib/log4j-1.2.11.jar"/>
<path location="${hbm.dir}/lib/commons-logging-1.0.4.jar"/>
<path location="${hbm.dir}/lib/commons-collections-2.1.1.jar"/>
<path location="${hbm.dir}/lib/cglib-2.1.3.jar"/>
<path location="${hbm.dir}/lib/ehcache-1.1.jar"/>
<path location="${hbm.dir}/lib/jta.jar"/>
<path location="${jdbc.driver.jar}"/>
</path>

<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib"/>

<target name="pojo" description="generate java pojo classes with hbm2java">
<hibernatetool destdir="${build.dir}">
<configuration configurationfile="${src.dir}/hibernate.cfg.xml">
<fileset dir="${src.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java/>
</hibernatetool>
</target>
</project>
-------------------------------------------------


hibernate.cfg.xml :
-------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.1//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="hibernate.connection.url">jdbc:microsoft:sqlserver://florence:1433;DatabaseName=AQM</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<!--<property name="query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>-->
<mapping resource="aria/Window.hbm.xml"/>
</session-factory>
</hibernate-configuration>
-------------------------------------------------

Window.hbm.xml
-------------------------------------------------
<?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 package="aria">
<class name="WindowTO" table="window">
<id name="id" column="id" type="java.lang.Integer">
<generator class="native"/>
</id>
<property name="keypad_address" column="keypad_address" type="java.lang.Integer" />
<property name="led_address" column="led_address" type="java.lang.Integer" />
<property name="deleted" column="deleted" type="java.lang.Boolean" />
<property name="code" column="code" type="java.lang.Integer" />
<property name="title" column="title" type="java.lang.String" />
<property name="password" column="password" type="java.lang.String" />
<property name="active" column="active" type="java.lang.Boolean" />
<property name="isSoftware" column="issoftware" type="java.lang.Boolean" />
<property name="type" column="type" type="java.lang.Boolean" />
</class>
</hibernate-mapping>
-------------------------------------------------

I got the output:
An exception occured while running exporter #2:hbm2java (Generates a set of .java files)
Failed in building configuration when adding D:\DevDesk\hibernateToolsTest\src\aria\Window.hbm.xml
org.hibernate.MappingException: Could not read mapping document from file: D:\DevDesk\hibernateToolsTest\src\aria\Window.hbm.xml
org.hibernate.DuplicateMappingException: Duplicate class/entity mapping aria.WindowTO
D:\DevDesk\hibernateToolsTest\build.xml:33: Failed in building configuration when adding D:\DevDesk\hibernateToolsTest\src\aria\Window.hbm.xml


I tried to find a documentation resource for DuplicateMappingException, without any success.
What's my mistake?

<Farshid/>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 10:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
my guess is that you duplicated your mappings (!) by including 2 mappings for the same class/entityname via filesets and the hibernate.cfg.xml

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 10:11 am 
Newbie

Joined: Mon Nov 28, 2005 10:09 am
Posts: 11
I'm trying to test and learn using hibernate-tools and there is no other files in the project except an empty class : aria.WindowTO

<Farshid/>


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 10:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so what is this file about: D:\DevDesk\hibernateToolsTest\src\aria\Window.hbm.xml ?

I bet you it is both included via your fileset AND in hibernate.cfg.xml

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 10:20 am 
Newbie

Joined: Mon Nov 28, 2005 10:09 am
Posts: 11
Thanks a lot. It seems that I'm not in the garden!!!

I omited one of the mappings and the problem resolved.

<Farshid/>


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.