-->
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.  [ 7 posts ] 
Author Message
 Post subject: diff. between eclipse plugin and ant generation.
PostPosted: Tue Jun 17, 2008 7:48 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
Hibernate version:3.2

Name and version of the database you are using: SQLServer 2005

I have some template based generation with eclipse plugin, which i want use with hibernateTool task in ant.

Both are configured with the same hibernate.cfg.xml, and the generated classes are annoted.

Here the ANT target:


Code:
   <target name="beanBase" depends="" description="--> description">
      <hibernatetool destdir="${bean.dir}/">
         <jdbcconfiguration detectmanytomany="true" configurationfile="${src.dir}\hibernate.cfg.xml" packagename="${bean.pac}" />
         <hbmtemplate exporterclass="org.hibernate.tool.hbm2x.POJOExporter" templatepath="${template.dir}" template="beanBase.ftl" filepattern="{package-name}\{class-name}Base.java">
            <property key="jdk5" value="true" />
            <property key="ejb3" value="true" />
         </hbmtemplate>
      </hibernatetool>
   </target>

(I try all exporterclass)

and in my hibernate Code generation dialog, i have a Generic Exporter with properties, file pattern... to the same values. The console point to the same hibernate.cfg.xml file than the ant target.


The two generation, Ant and eclipse plugin, give me the same generated files, except for a many-to-many, where eclipse plugin put properly a @JoinColumn attribute on a side of the association, the ant task generate a both side mappedBy in the @ManyToMany, which is non-functionnal.

For the association generation i use pojo/PojoPropertyAccessor.ftl

Did i miss anything?

Thank you by advance,
Regards,
Slimane.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 7:50 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
Even with hbm generation, the ant based generation will put two inverse="true" attributes where the eclipse plugin works well.

Isn't the same code executed when the configurations are similar?

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 9:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
do you have many to many detetction enabled in both ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 10:20 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
Quote:
do you have many to many detetction enabled in both ?


Yes, it is.

And as the hbmtemplate described before, the following hbm2java configuration give me a ManyToMany with mappedBy on both sides:

Code:
<target name="hbm2java" depends="" description="--> description">
      <hibernatetool destdir="${bean.dir}/">
         <jdbcconfiguration detectmanytomany="true" revengfile="${gen.dir}/hibernate.reveng.xml" configurationfile="${src.dir}\hibernate.cfg.xml" packagename="${bean.pac}" />
         <hbm2java jdk5="true" ejb3="true"/>
      </hibernatetool>
   </target>


whereas this config works well:

-A console (Type core) targeted on ${src.dir}\hibernate.cfg.xml
-A hibernate Code Generation with same outputdir, packagename, reveng.xml
\_>A generic exporter with jdk5,ejb3, same file pattern and template name

The eclipse output and Ant output are exactly the same, except the 2 mappedBy and the joinColumn missing.

Do you have a good generation with ANT in this config:
-2 tables + 1 Join table
-jdbcconfiguration detectmanytomany=true
-hbm2java jdk5=true ejb3=true

I try with hsql and sqlserver2005.

Thanks by advance,
Slimane.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 11:22 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
I have some traces:

Code:
2008-06-17 17:09:41,873 ERROR Worker-2 freemarker.runtime -

Method public java.lang.String org.hibernate.tool.hbm2x.pojo.EntityPOJOClass.generateJoinColumnsAnnotation(org.hibernate.mapping.Property,org.hibernate.cfg.Configuration) threw an exception when invoked on Entity: com.entreprise.appli.bean.Employe
The problematic instruction:
----------
==> ${pojo.generateJoinColumnsAnnotation(property)} [on line 15, column 1 in mypojo/Ejb3PropertyGetAnnotation.ftl]
in include "Ejb3PropertyGetAnnotation.ftl" [on line 9, column 5 in mypojo/PojoPropertyAccessors.ftl]
in include "mypojo/PojoPropertyAccessors.ftl" [on line 40, column 1 in beanBase.ftl]
----------

Java backtrace for programmers:
----------
freemarker.template.TemplateModelException: Method public java.lang.String org.hibernate.tool.hbm2x.pojo.EntityPOJOClass.generateJoinColumnsAnnotation(org.hibernate.mapping.Property,org.hibernate.cfg.Configuration) threw an exception when invoked on Entity: com.entreprise.appli.bean.Employe
   at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:136)
   at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:93)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Expression.getStringValue(Expression.java:93)
   at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.IfBlock.accept(IfBlock.java:82)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.include(Environment.java:1375)
   at freemarker.core.Include.accept(Include.java:155)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
   at freemarker.core.Environment.visit(Environment.java:351)
   at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.include(Environment.java:1375)
   at freemarker.core.Include.accept(Include.java:155)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.visit(Environment.java:233)
   at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.process(Environment.java:176)
   at freemarker.template.Template.process(Template.java:232)
   at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:255)
   at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67)
   at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
   at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:103)
   at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:148)
   at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:137)
   at org.hibernate.tool.hbm2x.GenericExporter$2.process(GenericExporter.java:43)
   at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:128)
   at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
   at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$1.execute(CodeGenerationLaunchDelegate.java:256)
   at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
   at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:88)
   at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:226)
   at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:134)
   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:759)
   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:608)
   at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:899)
   at org.eclipse.debug.internal.ui.DebugUIPlugin$7.run(DebugUIPlugin.java:1102)
   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.IllegalArgumentException: wrong number of arguments
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:616)
   at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:113)
   ... 57 more


So i add the parameter "cfg" to the call of the generateJoinColumnsAnnotation method. (but EntityPOJOClass.generaJoinColumsAnnotation(Property) exist and not with cfg)
After that, the problem is on the call to ${pojo.getCascadeType(property)}:


Code:
2008-06-17 17:12:54,485 ERROR Worker-8 freemarker.runtime -

Expression pojo.getCascadeType is undefined on line 11, column 63 in mypojo/Ejb3PropertyGetAnnotation.ftl.
The problematic instruction:
----------
==> ${pojo.getCascadeType(property)} [on line 11, column 61 in mypojo/Ejb3PropertyGetAnnotation.ftl]
in include "Ejb3PropertyGetAnnotation.ftl" [on line 9, column 5 in mypojo/PojoPropertyAccessors.ftl]
in include "mypojo/PojoPropertyAccessors.ftl" [on line 40, column 1 in beanBase.ftl]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: Expression pojo.getCascadeType is undefined on line 11, column 63 in mypojo/Ejb3PropertyGetAnnotation.ftl.
   at freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:124)
   at freemarker.core.TemplateObject.invalidTypeException(TemplateObject.java:134)
   at freemarker.core.MethodCall._getAsTemplateModel(MethodCall.java:114)
   at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
   at freemarker.core.Expression.getStringValue(Expression.java:93)
   at freemarker.core.DollarVariable.accept(DollarVariable.java:76)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.IfBlock.accept(IfBlock.java:82)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.include(Environment.java:1375)
   at freemarker.core.Include.accept(Include.java:155)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:79)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.IteratorBlock$Context.runLoop(IteratorBlock.java:160)
   at freemarker.core.Environment.visit(Environment.java:351)
   at freemarker.core.IteratorBlock.accept(IteratorBlock.java:95)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.include(Environment.java:1375)
   at freemarker.core.Include.accept(Include.java:155)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.visit(Environment.java:233)
   at freemarker.core.BlockAssignment.accept(BlockAssignment.java:83)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.MixedContent.accept(MixedContent.java:92)
   at freemarker.core.Environment.visit(Environment.java:196)
   at freemarker.core.Environment.process(Environment.java:176)
   at freemarker.template.Template.process(Template.java:232)
   at org.hibernate.tool.hbm2x.TemplateHelper.processTemplate(TemplateHelper.java:255)
   at org.hibernate.tool.hbm2x.TemplateProducer.produceToString(TemplateProducer.java:67)
   at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:28)
   at org.hibernate.tool.hbm2x.TemplateProducer.produce(TemplateProducer.java:103)
   at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:148)
   at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:137)
   at org.hibernate.tool.hbm2x.GenericExporter$2.process(GenericExporter.java:43)
   at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:128)
   at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
   at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate$1.execute(CodeGenerationLaunchDelegate.java:256)
   at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
   at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:88)
   at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.runExporters(CodeGenerationLaunchDelegate.java:226)
   at org.hibernate.eclipse.launch.CodeGenerationLaunchDelegate.launch(CodeGenerationLaunchDelegate.java:134)
   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:759)
   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:608)
   at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:899)
   at org.eclipse.debug.internal.ui.DebugUIPlugin$7.run(DebugUIPlugin.java:1102)
   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


Yet the method EntityPOJOClass.getCascadeType(Propery) exist in the jar.

I precise that i my libs hibernate3.jar and annotation come from hibernate-tools like recommended in the doc.


Thanks by advance and sorry for long post,
Regards,
Slimane.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 2:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes so something in your mappings (or db if you are doing reverse engineering) is causing the model to contain a null where it is not expected.

could you reduce it to a minimal testcase and attach it in jira and ill take a look.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 8:35 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
I see that the problem come from i tried to suffix the classnames, by adding extra +"Suffix" code in the .ftl. When i remove my hardcoded suffixes, the differents pojo.XXX() methods works fine. I surely use a bad technique to change the generated className.

I think it will be more clever to see with the reveng or naming strategies to do the job...

Thanks,
Regards,
Slimane.


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