-->
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: Target hbm2hbmxml does not work + HQL client
PostPosted: Thu Jun 21, 2007 8:43 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 3:26 am
Posts: 35
Location: Germany
Hi!

I want to generate hibernate mapping files from annotated entity classes. Unfortunately the use of the target hbm2hbmxml , which is supposed to be able to do this task, throws an exception when I use it. Does anyone know how I can get it to work?

I need to generate the mapping files because I want to use the Hibernate Tools Suite (https://hts.dev.java.net/) which can show the result of HQL Statements. Unfortunately this tool only supports hibernate mapping files and not annotations. The Hibernate-Tools plugin for Eclipse on the other hand supports hibernate annotations but we can't use it because my colleges in the support should use the tool too - and they want a simple HQL client not a complete development environment. So if anyone knows an other little, easy to use HQL client which knows how to parse annotated entites this would solve my problems too.

Hibernate version:
hibernare-3.2.2.ga
hibernate-annotations-3.3.0.GA
hibernate-entitymanager-3.3.1.GA
HibernateTools-3.2.0.beta9a

Ant target
Code:
<target name="createHibernateMappingFiles">
      <hibernatetool destdir="${build.dir}/hbm">
         <jpaconfiguration persistenceunit="${persistence_unit}" />

         <classpath>
            <!-- it is in this classpath you put your classes dir,
            and/or jpa persistence compliant jar -->
            <path location="${bin.dir}" />
         </classpath>

         <hbm2hbmxml />
      </hibernatetool>
   </target>


Full stack trace of any exception that occurs:
Code:
createHibernateMappingFiles:
[hibernatetool] Executing Hibernate Tool with a JPA Configuration
[hibernatetool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] 21.06.2007 14:23:17 org.hibernate.cfg.annotations.Version <clinit>
[hibernatetool] INFO: Hibernate Annotations 3.3.0.GA
[hibernatetool] 21.06.2007 14:23:17 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: Hibernate 3.2.2
[hibernatetool] 21.06.2007 14:23:17 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: hibernate.properties not found
[hibernatetool] 21.06.2007 14:23:17 org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] INFO: Bytecode provider name : cglib
[hibernatetool] 21.06.2007 14:23:17 org.hibernate.cfg.Environment <clinit>
[hibernatetool] INFO: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 21.06.2007 14:23:17 org.hibernate.ejb.Version <clinit>
[hibernatetool] INFO: Hibernate EntityManager 3.3.1.GA
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.AnnotationBinder bindClass
[hibernatetool] INFO: Binding entity from annotated class: com.globefuel.lm.persistence.entities.Functunality
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.annotations.EntityBinder bindTable
[hibernatetool] INFO: Bind entity com.globefuel.lm.persistence.entities.Functunality on table Functunality
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.AnnotationBinder bindClass
[hibernatetool] INFO: Binding entity from annotated class: com.globefuel.lm.persistence.entities.RightFunctunality
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.annotations.EntityBinder bindTable
[hibernatetool] INFO: Bind entity com.globefuel.lm.persistence.entities.RightFunctunality on table RightFunctunality
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.AnnotationBinder bindClass
[hibernatetool] INFO: Binding entity from annotated class: com.globefuel.lm.persistence.entities.Module
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.annotations.EntityBinder bindTable
[hibernatetool] INFO: Bind entity com.globefuel.lm.persistence.entities.Module on table Module
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.AnnotationBinder bindClass
[hibernatetool] INFO: Binding entity from annotated class: com.globefuel.lm.persistence.entities.Customer
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.annotations.EntityBinder bindTable
[hibernatetool] INFO: Bind entity com.globefuel.lm.persistence.entities.Customer on table Customer
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.AnnotationBinder bindClass
[hibernatetool] INFO: Binding entity from annotated class: com.globefuel.lm.persistence.entities.Function
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.annotations.EntityBinder bindTable
[hibernatetool] INFO: Bind entity com.globefuel.lm.persistence.entities.Function on table Function
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.AnnotationBinder bindClass
[hibernatetool] INFO: Binding entity from annotated class: com.globefuel.lm.persistence.entities.Licence
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.cfg.annotations.EntityBinder bindTable
[hibernatetool] INFO: Bind entity com.globefuel.lm.persistence.entities.Licence on table Licence
[hibernatetool] 21.06.2007 14:23:18 org.hibernate.validator.Version <clinit>
[hibernatetool] INFO: Hibernate Validator 3.0.0.GA
[hibernatetool] 21.06.2007 14:23:19 org.hibernate.tool.Version <clinit>
[hibernatetool] INFO: Hibernate Tools 3.2.0.b9
[hibernatetool] 21.06.2007 14:23:20 freemarker.log.JDK14LoggerFactory$JDK14Logger error
[hibernatetool] SCHWERWIEGEND:
[hibernatetool] Expression property.getValue().getElement().referencedEntityName is undefined on line 22, column 41 in hbm/bag.hbm.ftl.
[hibernatetool] The problematic instruction:
[hibernatetool] ----------
[hibernatetool] ==> ${property.getValue().getElement().referencedEntityName} [on line 22, column 39 in hbm/bag.hbm.ftl]
[hibernatetool] in include "${c2h.getTag(property)}.hbm.ftl" [on line 93, column 1 in hbm/persistentclass.hbm.ftl]
[hibernatetool] in include "persistentclass.hbm.ftl" [on line 34, column 1 in hbm/hibernate-mapping.hbm.ftl]
[hibernatetool] ----------
[hibernatetool] Java backtrace for programmers:
[hibernatetool] ----------
[hibernatetool] freemarker.core.InvalidReferenceException: Expression property.getValue().getElement().referencedEntityName is undefined on line 22, column 41 in hbm/bag.hbm.ftl.
[hibernatetool] at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
[hibernatetool] at freemarker.core.Expression.getStringValue(Expression.java:118)
[hibernatetool] at freemarker.core.Expression.getStringValue(Expression.java:93)
[hibernatetool] at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.IfBlock.accept(IfBlock.java:82)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.Environment.include(Environment.java:1375)
[hibernatetool] at freemarker.core.Include.accept(Include.java:155)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:351)
[hibernatetool] at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.Environment.include(Environment.java:1375)
[hibernatetool] at freemarker.core.Include.accept(Include.java:155)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.MixedContent.accept(MixedContent.java:92)
[hibernatetool] at freemarker.core.Environment.visit(Environment.java:196)
[hibernatetool] at freemarker.core.Environment.process(Environment.java:176)
[hibernatetool] at freemarker.template.Template.process(Template.java:231)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:247)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
[hibernatetool] at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:97)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:146)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:135)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter$2.process(GenericExporter.java:41)
[hibernatetool] at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:126)
[hibernatetool] at org.hibernate.tool.hbm2x.HibernateMappingExporter.doStart(HibernateMappingExporter.java:34)
[hibernatetool] at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
[hibernatetool] at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
[hibernatetool] at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:183)
[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.Target.performTasks(Target.java:369)
[hibernatetool] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[hibernatetool] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[hibernatetool] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
[hibernatetool] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
[hibernatetool] at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
[hibernatetool] An exception occurred while running exporter #2:hbm2hbmxml (Generates a set of hbm.xml files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.tool.hbm2x.ExporterException: Error while processing template hbm/hibernate-mapping.hbm.ftl
[hibernatetool] freemarker.core.InvalidReferenceException: Expression property.getValue().getElement().referencedEntityName is undefined on line 22, column 41 in hbm/bag.hbm.ftl.

BUILD FAILED
C:\Development\java_wsp\licence_manager\build.xml:60: org.hibernate.tool.hbm2x.ExporterException: Error while processing template hbm/hibernate-mapping.hbm.ftl


Thanks
Hoeft


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 22, 2007 3:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
1) hts.dev.java.net is in Netbeans - why is that not considered a complete environment ?

2) hibernate tools just require JDT for its code completion and reflection on java info. You don't have to use all the buttons ;)

3) relying on hbm2hbmxml is not healthy, it doesn't not convert everything 100%

_________________
Max
Don't forget to rate


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.