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

问题描述

照网上方法,试了很多,但仍解决不了。=========================================================================================================12:01:14,672  INFO Version:37 - HCANN000001: Hibernate Commons Annotations {4.0.1.Final}12:01:14,721  INFO Version:41 - HHH000412: Hibernate Core {4.1.10.Final}12:01:14,731  INFO Environment:239 - HHH000206: hibernate.properties not found12:01:14,734  INFO Environment:342 - HHH000021: Bytecode provider name : javassist12:01:14,783  INFO Configuration:1926 - HHH000043: Configuring from resource: /hibernate.cfg.xml12:01:14,784  INFO Configuration:1945 - HHH000040: Configuration resource: /hibernate.cfg.xml12:01:15,199  INFO Configuration:718 - HHH000221: Reading mappings from resource: cn/jhost/alibaba/user/vo/UserModel.hbm.xml12:01:15,522  INFO Configuration:2067 - HHH000041: Configured SessionFactory: nullorg.hibernate.InvalidMappingException: Could not parse mapping document from resource cn/jhost/alibaba/user/vo/UserModel.hbm.xmlat org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3423)at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3412)at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3400)at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1330)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1730)at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1781)at cn.jhost.alibaba.common.HibernateUtil.<clinit>(HibernateUtil.java:13)at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:68)at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:1)at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:22)at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:1)at cn.jhost.alibaba.user.business.factory.UserEbiFactory.main(UserEbiFactory.java:20)Caused by: org.hibernate.PropertyNotFoundException: field [password] not found on cn.jhost.alibaba.user.vo.UserModelat org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:182)at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:174)at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:197)at org.hibernate.internal.util.ReflectHelper.getter(ReflectHelper.java:253)at org.hibernate.internal.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:229)at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:324)at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2311)at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2276)at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2166)at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:407)at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:322)at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:173)at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3420)... 11 moreException in thread "main" java.lang.NullPointerExceptionat cn.jhost.alibaba.common.HibernateUtil.currentSession(HibernateUtil.java:26)at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:68)at cn.jhost.alibaba.user.dao.Impl.H4Impl.getByCondition(H4Impl.java:1)at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:22)at cn.jhost.alibaba.user.business.ebo.UserEbo.getByCondition(UserEbo.java:1)at cn.jhost.alibaba.user.business.factory.UserEbiFactory.main(UserEbiFactory.java:20)===============================================================================================<?xml version="1.0" encoding='utf-8'?><!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN""http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping>     <class name="cn.jhost.alibaba.user.vo.UserModel" table="tbl_user"  dynamic-insert="true" dynamic-update="true" optimistic-lock="version">    <id name="uuid">    <generator class="uuid"/>    </id>    <version name="version" column="version"/>    <property name="name" column="name" />    <property name="password" column="password"/><property name="type" column="type"/> </class> </hibernate-mapping>====================================================================================<?xml version='1.0' encoding='utf-8'?><!DOCTYPE hibernate-configuration PUBLIC"-//Hibernate/Hibernate Configuration DTD 3.0//EN""http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration>     <session-factory>         <property name="connection.driver_class">com.mysql.jdbc.Driver</property>        <property name="connection.url">jdbc:mysql://localhost:3306/alibaba?useUnicode=true&amp;characterEncoding=UTF-8</property>        <property name="connection.username">root</property>        <property name="connection.password">123456</property> <property name="c3p0.min_size">5</property>        <property name="c3p0.max_size">20</property>        <property name="c3p0.timeout">180</property>        <property name="c3p0.max_statements">5</property>                <property name="dialect">org.hibernate.dialect.MySQLDialect</property>         <!-- Enable Hibernate's automatic session context management -->        <property name="current_session_context_class">thread</property>         <property name="show_sql">true</property><property name="format_sql">true</property>          <mapping resource="cn/jhost/alibaba/user/vo/UserModel.hbm.xml"/>     </session-factory> </hibernate-configuration>

解决方案

org.hibernate.PropertyNotFoundException: field [password] not found on cn.jhost.alibaba.user.vo.UserModel你的cn.jhost.alibaba.user.vo.UserModel 里边有 password属性吗? 贴下看看
解决方案二:
错误不是很明显了么?Caused by: org.hibernate.PropertyNotFoundException: field [password] not found on cn.jhost.alibaba.user.vo.UserModelcn.jhost.alibaba.user.vo.UserModel这个类中没有password属性,而你的配置文件中确有这个字段,检查一下吧。

时间: 2024-09-18 08:08:42

org.hibernate.InvalidMappingException: Could not parse mapping document from的相关文章

hibernate-Could not parse mapping document from resource

问题描述 Could not parse mapping document from resource Employee.hbm.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourc

Could not parse mapping document from input stream

问题描述 严重:Exceptionsendingcontextinitializedeventtolistenerinstanceofclassorg.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'sessionFactory'definedinclasspathresource[a

hibernate 日志异常

问题描述 最近学习hibernate,看书感觉可以,实际操作怎么就那么难呢!我用的是:hibernate3.2 eclipse3.3 (没有Myeclipse插件) Mysql6.0一:main()函数 package org.first;import org.hibernate.*;import org.hibernate.cfg.*;public abstract class FirstM {/** * @param args */public static void main(String

刚刚学习hibernate,出了点错,大神能帮我看看吗?

问题描述 刚刚学习hibernate,出了点错,大神能帮我看看吗? org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.component.PojoComponentTuplizer] at org.hibernate.tuple.component.ComponentTuplizerFactory.constructTuplizer(ComponentTupl

Hibernate 异常找不到持久化类的配置文件,郁闷!

问题描述 hibernate 配置文件如下:<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><

项目启动时报错Element type "property" must be followed by either attri

项目启动时报错Element type "property" must be followed by either attribute specifications, ">" or "/>" 项目启动时,控制台报错,信息如下(有删减): Error creating bean with name 'supplierInfoDAO' defined in class path resource [conf/applicationCont

initialization-启动tomcat报错:好像是hbm.xml的问题

问题描述 启动tomcat报错:好像是hbm.xml的问题 10:19:25,238 ERROR ContextLoader:215 - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deparrtmentDaoImpl': Injection of resource fields failed; neste

求大神解答-求BeanCreationException的解决方案

问题描述 求BeanCreationException的解决方案 ERROR ContextLoader:308 - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]:

tomcat的加载配置文件不完全问题,偶尔会包这个错误,大部分时间又正常没错

问题描述 tomcat的加载配置文件不完全问题,偶尔会包这个错误,大部分时间又正常没错 信息: Initializing Spring root WebApplicationContext log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system properly.