-->
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.  [ 3 posts ] 
Author Message
 Post subject: Codegen Clarification - Property Type Attribute
PostPosted: Wed Sep 21, 2005 5:30 am 
Newbie

Joined: Sat Sep 03, 2005 6:31 am
Posts: 7
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 12:30 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
The tool needs to know the type of the persistent property. This is not in the mapping file so H searches the classpath for the class itself in order to determine this using reflection. This is why you have a CNFE . You are going to have to put the class in the classpath, or specify the type in the mapping doc.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 1:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
"From Hibernate In Action, I could understand that whenever a type is not omitted, Hibernate assumes a string type."

Where is that ? Don't think it says that.

_________________
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.  [ 3 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.