-->
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.  [ 6 posts ] 
Author Message
 Post subject: Strange errormsg when trying to run my named query file!
PostPosted: Tue Feb 05, 2008 1:20 pm 
Regular
Regular

Joined: Mon May 22, 2006 4:28 am
Posts: 56
Location: Göteborg, Sweden
Hi All,
I had a older version of hibernate tools working with reverse engineering where I generate my DAO Interface and DAO Impl using named queries to add extra methods. When I now try to move this functionallity into my new project I get a strange error.

Code:
[hibernatetool] Failed in building configuration when adding C:\DevArea2\projects\webshop\hibernate\
namedqueries\namedQueries-appuser.hbm.xml
[hibernatetool] org.hibernate.InvalidMappingException: Could not parse mapping document from file C:
\DevArea2\projects\webshop\hibernate\namedqueries\namedQueries-appuser.hbm.xml
[hibernatetool] org.hibernate.DuplicateMappingException: Duplicate query mapping com.bergoo.webshop.
data.model.AppUser.findUniqueEnabledUserByUsername


My namedQueries-appuser.hbm.xml look like this:
Code:
<?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>
   
   <query name="com.bergoo.webshop.data.model.AppUserRole.findByUsername">
        from AppUserRole where userName = ?
        <query-param name="userName" type="string" />
   </query>
   
   <query name="com.bergoo.webshop.data.model.AppUserRole.findUniqueByUsernameAndAppUserRole">
        from AppUserRole where userName = ? and userRole = ?
        <query-param name="userName" type="string" />
        <query-param name="userRole" type="string" />
   </query>

</hibernate-mapping>


I even tried to run the ant script with an empty file, just <hibernate_mapping></hibernate-mapping> but the error msg stays the same as if it didn't care about the content.

Does anybody know how to solve this? Thanks for any help/pointers

Jacob

Here is the full stack trace of the error!
Code:
Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: build.xml
Detected Java version: 1.6 in: C:\Program Files\Java\jdk1.6.0_04\jre
Detected OS: Windows Vista
parsing buildfile C:\DevArea2\projects\webshop\build.xml with URI = file:/C:/DevArea2/projects/websh
op/build.xml
Project base dir set to: C:\DevArea2\projects\webshop
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.x
ml. It could not be found.
[property] Loading C:\DevArea2\projects\webshop\src\main\resources\build.properties
Property "web-lib.dir" has not been set
    [javac] java\com\bergoo\persistenceutils\ApplicationContextUtils.java added as java\com\bergoo\p
ersistenceutils\ApplicationContextUtils.class doesn't exist.
    [javac] java\com\bergoo\persistenceutils\GenerateNamedQueryFilesAndSettingsUtils.java added as j
ava\com\bergoo\persistenceutils\GenerateNamedQueryFilesAndSettingsUtils.class doesn't exist.
    [javac] java\com\bergoo\persistenceutils\GeneratedFilesUtils.java added as java\com\bergoo\persi
stenceutils\GeneratedFilesUtils.class doesn't exist.
    [javac] java\com\bergoo\persistenceutils\RevEngStrategy.java added as java\com\bergoo\persistenc
eutils\RevEngStrategy.class doesn't exist.
    [javac] Compiling 4 source files to C:\DevArea2\projects\webshop\target\classes\com\bergoo\persi
stenceutils
    [javac] Using modern compiler
    [javac] Compilation arguments:
    [javac] '-d'
    [javac] 'C:\DevArea2\projects\webshop\target\classes\com\bergoo\persistenceutils'
    [javac] '-classpath'
    [javac] 'C:\DevArea2\projects\webshop\target\classes\com\bergoo\persistenceutils;C:\DevArea2\pro
jects\webshop\hibernate\toolslib\asm.jar;C:\DevArea2\projects\webshop\hibernate\toolslib\cglib-2.1_3
.jar;C:\DevArea2\projects\webshop\hibernate\toolslib\commons-collections-2.1.1.jar;C:\DevArea2\proje
cts\webshop\hibernate\toolslib\commons-logging-1.1.jar;C:\DevArea2\projects\webshop\hibernate\toolsl
ib\dom4j-1.6.1.jar;C:\DevArea2\projects\webshop\hibernate\toolslib\freemarker-2.3.8.jar;C:\DevArea2\
projects\webshop\hibernate\toolslib\hibernate-3.2.5.ga.jar;C:\DevArea2\projects\webshop\hibernate\to
olslib\hibernate-annotations.jar;C:\DevArea2\projects\webshop\hibernate\toolslib\hibernate-tools-3.2
.0.ga.jar;C:\DevArea2\projects\webshop\hibernate\toolslib\jgroups-2.2.8.jar;C:\DevArea2\projects\web
shop\hibernate\toolslib\jtidy-r8-20060801.jar;C:\DevArea2\projects\webshop\hibernate\toolslib\log4j-
1.2.9.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-launcher.jar;C:\Program Files\apache-ant-1.7.0\l
ib\ant-antlr.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-apache-bcel.jar;C:\Program Files\apache-a
nt-1.7.0\lib\ant-apache-bsf.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-apache-log4j.jar;C:\Progra
m Files\apache-ant-1.7.0\lib\ant-apache-oro.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-apache-reg
exp.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-apache-resolver.jar;C:\Program Files\apache-ant-1.
7.0\lib\ant-commons-logging.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-commons-net.jar;C:\Program
Files\apache-ant-1.7.0\lib\ant-jai.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-javamail.jar;C:\Pr
ogram Files\apache-ant-1.7.0\lib\ant-jdepend.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-jmf.jar;C
:\Program Files\apache-ant-1.7.0\lib\ant-jsch.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-junit.ja
r;C:\Program Files\apache-ant-1.7.0\lib\ant-netrexx.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-no
deps.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-starteam.jar;C:\Program Files\apache-ant-1.7.0\li
b\ant-stylebook.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-swing.jar;C:\Program Files\apache-ant-
1.7.0\lib\ant-testutil.jar;C:\Program Files\apache-ant-1.7.0\lib\ant-trax.jar;C:\Program Files\apach
e-ant-1.7.0\lib\ant-weblogic.jar;C:\Program Files\apache-ant-1.7.0\lib\ant.jar;C:\Program Files\apac
he-ant-1.7.0\lib\asm.jar;C:\Program Files\apache-ant-1.7.0\lib\cglib-2.1_3.jar;C:\Program Files\apac
he-ant-1.7.0\lib\commons-collections-2.1.1.jar;C:\Program Files\apache-ant-1.7.0\lib\commons-logging
-1.1.jar;C:\Program Files\apache-ant-1.7.0\lib\dom4j-1.6.1.jar;C:\Program Files\apache-ant-1.7.0\lib
\freemarker-2.3.8.jar;C:\Program Files\apache-ant-1.7.0\lib\hibernate-3.2.5.ga.jar;C:\Program Files\
apache-ant-1.7.0\lib\hibernate-tools-3.2.0.ga.jar;C:\Program Files\apache-ant-1.7.0\lib\jtidy-r8-200
60801.jar;C:\Program Files\apache-ant-1.7.0\lib\xercesImpl.jar;C:\Program Files\apache-ant-1.7.0\lib
\xml-apis.jar;C:\Program Files\Java\jdk1.6.0_04\lib\tools.jar'
    [javac] '-sourcepath'
    [javac] 'C:\DevArea2\projects\webshop\hibernate\src'
    [javac] '-g:none'
    [javac]
    [javac] The ' characters around the executable and arguments are
    [javac] not part of the command.
    [javac] Files to be compiled:
    [javac]     C:\DevArea2\projects\webshop\hibernate\src\java\com\bergoo\persistenceutils\Applicat
ionContextUtils.java
    [javac]     C:\DevArea2\projects\webshop\hibernate\src\java\com\bergoo\persistenceutils\Generate
NamedQueryFilesAndSettingsUtils.java
    [javac]     C:\DevArea2\projects\webshop\hibernate\src\java\com\bergoo\persistenceutils\Generate
dFilesUtils.java
    [javac]     C:\DevArea2\projects\webshop\hibernate\src\java\com\bergoo\persistenceutils\RevEngSt
rategy.java
Build sequence for target(s) `generateHibernateDaoInterfaceClasses' is [generateHibernateDaoInterfac
eClasses]
Complete build sequence is [generateHibernateDaoInterfaceClasses, clean-all, compile-app, create-exp
loded-war, generateHibernateDaoImplClasses, moveGeneratedFiles, info, GenerateNamedQueryFilesAndSett
ingsUtils, help, runTests, generateApplicationContextFiles, , generateHibernateDaoTestClasses]

generateHibernateDaoInterfaceClasses:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: generic exportertemplate: daointerface.ftl
[hibernatetool] 05/02/2008 12:08:07 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.2.5
[hibernatetool] 05/02/2008 12:08:07 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] 05/02/2008 12:08:07 PM org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] INFO: Bytecode provider name : cglib
[hibernatetool] 05/02/2008 12:08:07 PM org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 05/02/2008 12:08:07 PM org.hibernate.cfg.Configuration configure
[hibernatetool] INFO: configuring from file: hibernate.cfg.xml
[hibernatetool] 05/02/2008 12:08:07 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-appuser.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-appuserrole.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-communicationboard.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-communicationboardfile.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-customer.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-customeraddress.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-customeremail.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-customerphone.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-employee.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-employeeaddress.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-employeeemail.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-employeephone.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-loginevent.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-userrole.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-website.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration doConfigure
[hibernatetool] INFO: Configured SessionFactory: null
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedquerie
s\namedQueries-appuser.hbm.xml
[hibernatetool] An exception occurred while running exporter #2:generic exportertemplate: daointerfa
ce.ftl
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] Failed in building configuration when adding C:\DevArea2\projects\webshop\hibernate\
namedqueries\namedQueries-appuser.hbm.xml
[hibernatetool] org.hibernate.InvalidMappingException: Could not parse mapping document from file C:
\DevArea2\projects\webshop\hibernate\namedqueries\namedQueries-appuser.hbm.xml
[hibernatetool] org.hibernate.DuplicateMappingException: Duplicate query mapping com.bergoo.webshop.
data.model.AppUser.findUniqueEnabledUserByUsername

BUILD FAILED
C:\DevArea2\projects\webshop\build.xml:94: Failed in building configuration when adding C:\DevArea2\
projects\webshop\hibernate\namedqueries\namedQueries-appuser.hbm.xml
        at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:155)
        at org.hibernate.tool.ant.ConfigurationTask.addMappings(ConfigurationTask.java:133)
        at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:97)
        at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
        at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
        at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
        at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
        at org.hibernate.tool.ant.GenericExporterTask.configureExporter(GenericExporterTask.java:65)

        at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.Main.runBuild(Main.java:698)
        at org.apache.tools.ant.Main.startAnt(Main.java:199)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from file C:\DevA
rea2\projects\webshop\hibernate\namedqueries\namedQueries-appuser.hbm.xml
        at org.hibernate.cfg.Configuration.addFile(Configuration.java:319)
        at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:150)
        ... 26 more
Caused by: org.hibernate.DuplicateMappingException: Duplicate query mapping com.bergoo.webshop.data.
model.AppUser.findUniqueEnabledUserByUsername
        at org.hibernate.cfg.Mappings.checkQueryExist(Mappings.java:270)
        at org.hibernate.cfg.Mappings.addQuery(Mappings.java:259)
        at org.hibernate.cfg.HbmBinder.bindNamedQuery(HbmBinder.java:2599)
        at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:160)
        at org.hibernate.cfg.Configuration.add(Configuration.java:669)
        at org.hibernate.cfg.Configuration.addFile(Configuration.java:309)
        ... 27 more
--- Nested Exception ---
org.hibernate.InvalidMappingException: Could not parse mapping document from file C:\DevArea2\projec
ts\webshop\hibernate\namedqueries\namedQueries-appuser.hbm.xml
        at org.hibernate.cfg.Configuration.addFile(Configuration.java:319)
        at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:150)
        at org.hibernate.tool.ant.ConfigurationTask.addMappings(ConfigurationTask.java:133)
        at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:97)
        at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
        at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
        at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
        at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
        at org.hibernate.tool.ant.GenericExporterTask.configureExporter(GenericExporterTask.java:65)

        at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
        at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
        at org.apache.tools.ant.Main.runBuild(Main.java:698)
        at org.apache.tools.ant.Main.startAnt(Main.java:199)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Caused by: org.hibernate.DuplicateMappingException: Duplicate query mapping com.bergoo.webshop.data.
model.AppUser.findUniqueEnabledUserByUsername
        at org.hibernate.cfg.Mappings.checkQueryExist(Mappings.java:270)
        at org.hibernate.cfg.Mappings.addQuery(Mappings.java:259)
        at org.hibernate.cfg.HbmBinder.bindNamedQuery(HbmBinder.java:2599)
        at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:160)
        at org.hibernate.cfg.Configuration.add(Configuration.java:669)
        at org.hibernate.cfg.Configuration.addFile(Configuration.java:309)
        ... 27 more

Total time: 3 seconds


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 5:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Code:
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedqueries\namedQueries-appuser.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedqueries\namedQueries-appuserrole.hbm.xml
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration
....
....
[hibernatetool] 05/02/2008 12:08:08 PM org.hibernate.cfg.Configuration addFile
[hibernatetool] INFO: Reading mappings from file: C:\DevArea2\projects\webshop\hibernate\namedqueries\namedQueries-appuser.hbm.xml


Adding the same mapping file twice will obviously give you parsing errors since you will have naming collisions.

check your cfg.xml and filesets in the ant config to see if you are actually specfiying the hbm.xml multiple times.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 10:30 am 
Regular
Regular

Joined: Mon May 22, 2006 4:28 am
Posts: 56
Location: Göteborg, Sweden
max wrote:
[code]
Adding the same mapping file twice will obviously give you parsing errors since you will have naming collisions.

check your cfg.xml and filesets in the ant config to see if you are actually specfiying the hbm.xml multiple times.


Hi Max!
yes, I see that it is added twice, but I don't understand why? I haven't changes anything in this part since my other project where I used Hibernate tools 3.2 beta 7.

Anyway, this is how my config looks like:

[code]
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- This connection URL is for the development database -->
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/webshop</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-appuser.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-appuserrole.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-communicationboard.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-communicationboardfile.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-customer.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-customeraddress.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-customeremail.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-customerphone.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-employee.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-employeeaddress.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-employeeemail.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-employeephone.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-loginevent.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-userrole.hbm.xml"/>
<mapping file="C:/DevArea2/projects/webshop/hibernate/namedqueries/namedQueries-website.hbm.xml"/>
</session-factory>
</hibernate-configuration>
[/code]

and my ant script:
[code]
<target name="generateHibernateDaoImplClasses">
<hibernatetool>
<configuration
configurationfile="${hibernateRootDir}/hibernate.cfg.xml">
<fileset dir="${hibernateRootDir}">
<include name="/namedqueries/*.hbm.xml"/>
</fileset>
<fileset dir="${hibernateMappingFileLocation}">
<include name="*.hbm.xml"/>
</fileset>
</configuration>

<hbmtemplate
filepattern="{class-name}DaoImpl.java"
templatepath="${hibernateRootDir}/template/dao"
template="daoimpl.ftl"
destdir="${hibernateDaoLocation}">
<property key="jdk5" value="true"/>
<property key="ejb3" value="false"/>
</hbmtemplate>
</hibernatetool>
</target>
[/code]

I tried to take out either the namedqueries files in the cfg.xml or in the ant script but then it generates the classes, but with no namedqueries additions...

I can't see why Hibernate tools pulls in the last file again... and why it only pulls in that one. I also verified that I don't have any additional mapping files added through the UI under the tab Mappings.

I am stuck with this one and really thankful for any help,
Jacob


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 2:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Look closely at your pasted cfg.xml and ant target once more... i'll wait...

...
...
...
...
...see it ?

hibernate.cfg.xml contains the hbm.xml files once and then you use a fileset to include all *.hbm.xml files once more that gives the overlap ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 5:18 pm 
Regular
Regular

Joined: Mon May 22, 2006 4:28 am
Posts: 56
Location: Göteborg, Sweden
Yes, as I mentioned I tried to take that out and I got rid of the error msg, but it didn't generate the named queries as extra methods in the dao. I found out that My misstake was that the package declaration was wrong.

Sorry about taking your time with something that was my misstake from the beginning....

Cheers,
Jacob


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 04, 2008 6:01 pm 
Regular
Regular

Joined: Tue Jul 29, 2008 4:15 pm
Posts: 62
Location: Dallas, TX US
Hi,

I am new to hibernate Tools and I also want to use named queries in my DAOs. Can someone explain step how to do this?

Thanks!

_________________
pouncilt


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