org.hibernate.InvalidMappingException: Could not parse mapping document from res

Buildfile: E:\workspace\Projects\hibernatetool\build.xml
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] 2010-4-22 14:09:11 org.hibernate.cfg.Environment <clinit>
[hibernatetool] 信息: Hibernate 3.2.5
[hibernatetool] 2010-4-22 14:09:11 org.hibernate.cfg.Environment <clinit>
[hibernatetool] 信息: hibernate.properties not found
[hibernatetool] 2010-4-22 14:09:11 org.hibernate.cfg.Environment buildBytecodeProvider
[hibernatetool] 信息: Bytecode provider name : cglib
[hibernatetool] 2010-4-22 14:09:11 org.hibernate.cfg.Environment <clinit>
[hibernatetool] 信息: using JDK 1.4 java.sql.Timestamp handling
[hibernatetool] 2010-4-22 14:09:12 org.hibernate.cfg.Configuration configure
[hibernatetool] 信息: configuring from file: hibernate.cfg.xml
[hibernatetool] 2010-4-22 14:09:12 org.hibernate.cfg.Configuration addResource
[hibernatetool] 信息: Reading mappings from resource : DocumentCatalog.hbm.xml
[hibernatetool] 2010-4-22 14:09:12 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
[hibernatetool] 信息: Mapping class: com.bigbuddy.oa.bean.DocumentCatalog -> documentCatalog
[hibernatetool] An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
[hibernatetool] To get the full stack trace run ant with -verbose
[hibernatetool] org.hibernate.InvalidMappingException: Could not parse mapping document from resource DocumentCatalog.hbm.xml
[hibernatetool] org.hibernate.MappingException: class com.bigbuddy.oa.bean.DocumentCatalog not found while looking for property: flag
[hibernatetool] java.lang.ClassNotFoundException: com.bigbuddy.oa.bean.DocumentCatalog
[hibernatetool] A class were not found in the classpath of the Ant task.
[hibernatetool] Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.

BUILD FAILED
E:\workspace\Projects\hibernatetool\build.xml:17: org.hibernate.InvalidMappingException: Could not parse mapping document from resource DocumentCatalog.hbm.xml

Total time: 764 milliseconds

 异常信息如上。

原因为:

HBM文件中的属性没有声明type类型,这种HBM文件在已经写好javaBean后再由HBM生成Shema时是没有问题的,因为它可以通过javaBean来得到相应的类型,但是,如果想从HBM中生成javaBean如果不指定类型就不可以了。

在hbm中加入属性的type后成功解决,根据相应的hbm和数据库表生成javaBean

 

 

参考:http://lisong0624.blog.163.com/blog/static/1887198620103202522410/

你可能感兴趣的:(sql,Hibernate,bean,xml,ant)