Hi,
I have the task to convert programmatically accessible non-Hibernate mapping metadata to Hibernate mapping metadata. I chose to use my own slightly changed version of Hibernate Tools - I'm in the process of writing my own Configuration (the import part).
Is there a way to avoid the entity-name property in the generated mapping files?
If I don't set the entity name like this
Code:
RootClass rc = new RootClass();
...
rc.setEntityName(entityName);
then (if I
DON'T set it) a NullPointerException occurs:
Code:
...
[my-hibernatetool] 10000 [main] DEBUG org.hibernate.tool.hbm2x.TemplateHelper - putInContext cfg=my-package.MyMetaDataConfiguration@11ed166
[my-hibernatetool] 10000 [main] DEBUG org.hibernate.tool.hbm2x.TemplateHelper - putInContext hmgs=org.hibernate.tool.hbm2x.HibernateMappingGlobalSettings@45aa2c
[my-hibernatetool] An exception occurred while running exporter #2:hbm2hbmxml (Generates a set of hbm.xml files)
[my-hibernatetool] To get the full stack trace run ant with -verbose
[my-hibernatetool] java.lang.NullPointerException
BUILD FAILED
C:\workspace\my-project\build.xml:74: java.lang.NullPointerException
at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:229)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:192)
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:585)
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.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by: java.lang.NullPointerException
at org.hibernate.util.StringHelper.unqualify(StringHelper.java:127)
at org.hibernate.tool.hbm2x.HibernateMappingExporter.getClassNameForFile(HibernateMappingExporter.java:61)
at org.hibernate.tool.hbm2x.GenericExporter.resolveFilename(GenericExporter.java:150)
at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:142)
at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:135)
at org.hibernate.tool.hbm2x.GenericExporter$2.process(GenericExporter.java:41)
at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:126)
at org.hibernate.tool.hbm2x.HibernateMappingExporter.doStart(HibernateMappingExporter.java:34)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:189)
... 16 more
--- Nested Exception ---
java.lang.NullPointerException
at org.hibernate.util.StringHelper.unqualify(StringHelper.java:127)
at org.hibernate.tool.hbm2x.HibernateMappingExporter.getClassNameForFile(HibernateMappingExporter.java:61)
at org.hibernate.tool.hbm2x.GenericExporter.resolveFilename(GenericExporter.java:150)
at org.hibernate.tool.hbm2x.GenericExporter.exportPOJO(GenericExporter.java:142)
at org.hibernate.tool.hbm2x.GenericExporter.exportPersistentClass(GenericExporter.java:135)
at org.hibernate.tool.hbm2x.GenericExporter$2.process(GenericExporter.java:41)
at org.hibernate.tool.hbm2x.GenericExporter.doStart(GenericExporter.java:126)
at org.hibernate.tool.hbm2x.HibernateMappingExporter.doStart(HibernateMappingExporter.java:34)
at org.hibernate.tool.hbm2x.AbstractExporter.start(AbstractExporter.java:95)
at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:40)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:189)
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:585)
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.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)