Hi,
I am using
Hibernate 3.1 Beta 3
Hibernate Tools 3.1.0 alpha 6
J2SDK 1.4.2_08
Ant 1.6.5
the following is my mapping document
<?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>
<class name="com.medicom.hia.Sample1" table="SAMPLE1">
<id name="id" column="ID" type="long">
<generator class="native" />
</id>
<property name="fullName"/>
</class>
</hibernate-mapping>
Running codegen using Ant task,with org.hibernate.tool.ant.HibernateToolTask fails with the following error (Stack Trace pasted below).
D:\chandra\persistence_tools\hia\build.xml:31: Failed in building configuration when adding D:\chandra\persistence_tools\hia\src\com\medicom\hia\Test.hbm.xml
at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:145)
at org.hibernate.tool.ant.ConfigurationTask.addMappings(ConfigurationTask.java:123)
at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:109)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:158)
at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:73)
at org.hibernate.tool.ant.Hbm2JavaGeneratorTask.configureExporter(Hbm2JavaGeneratorTask.java:37)
at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:31)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:122)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: org.hibernate.MappingException: Could not read mapping document from file: D:\chandra\persistence_tools\hia\src\com\medicom\hia\Test.hbm.xml
at org.hibernate.cfg.Configuration.addFile(Configuration.java:263)
at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:140)
... 20 more
Caused by: org.hibernate.MappingException: class com.medicom.hia.Sample1 not found while looking for property: fullName
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:80)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276)
at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2064)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2049)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1939)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:370)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:284)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:155)
at org.hibernate.cfg.Configuration.add(Configuration.java:379)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:418)
at org.hibernate.cfg.Configuration.addFile(Configuration.java:260)
... 21 more
Caused by: java.lang.ClassNotFoundException: com.medicom.hia.Sample1
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1166)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1107)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:977)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:76)
... 31 more
--- Nested Exception ---
org.hibernate.MappingException: Could not read mapping document from file: D:\chandra\persistence_tools\hia\src\com\medicom\hia\Test.hbm.xml
at org.hibernate.cfg.Configuration.addFile(Configuration.java:263)
at org.hibernate.tool.ant.ConfigurationTask.addFile(ConfigurationTask.java:140)
at org.hibernate.tool.ant.ConfigurationTask.addMappings(ConfigurationTask.java:123)
at org.hibernate.tool.ant.ConfigurationTask.doConfiguration(ConfigurationTask.java:109)
at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:158)
at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:73)
at org.hibernate.tool.ant.Hbm2JavaGeneratorTask.configureExporter(Hbm2JavaGeneratorTask.java:37)
at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:31)
at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:122)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
at org.apache.tools.ant.Task.perform(Task.java:364)
at org.apache.tools.ant.Target.execute(Target.java:341)
at org.apache.tools.ant.Target.performTasks(Target.java:369)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
at org.apache.tools.ant.Main.runBuild(Main.java:668)
at org.apache.tools.ant.Main.startAnt(Main.java:187)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: org.hibernate.MappingException: class com.medicom.hia.Sample1 not found while looking for property: fullName
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:80)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276)
at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2064)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2049)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1939)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:370)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:284)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:155)
at org.hibernate.cfg.Configuration.add(Configuration.java:379)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:418)
at org.hibernate.cfg.Configuration.addFile(Configuration.java:260)
... 21 more
Caused by: java.lang.ClassNotFoundException: com.medicom.hia.Sample1
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1166)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1107)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:977)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:108)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:76)
... 31 more
Adding a
type="string" to the
fullName property resolves the issue, but is the type attribute mandatory for a property mapping ?? From the hibernate-mapping-3.0.dtd it seems like an optional attribute (<!ATTLIST property type CDATA #IMPLIED>)
From Hibernate In Action, I could understand that whenever a type is not omitted, Hibernate assumes a string type.
Is this correct or am I doing something wrong.
Thanks in Advance.
Chandrasekhar