-->
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: Avoid entity-name in mapping file
PostPosted: Thu Jan 17, 2008 9:04 am 
Beginner
Beginner

Joined: Mon Jul 23, 2007 12:37 pm
Posts: 24
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)


Top
 Profile  
 
 Post subject: **SOLVED**
PostPosted: Thu Jan 17, 2008 9:30 am 
Beginner
Beginner

Joined: Mon Jul 23, 2007 12:37 pm
Posts: 24
O.K., I'm in the happy position to answer myself :-)
Solved by setting the class name instead of the entity name:

Code:
rc.setEntityName(myPersistentClass.getQualifiedName());

(myPersistentClass is a PersistentClass from the old mapper, getQualifiedName does - guess what? - give me the qualified class name.)


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.