求助!hibernate的映射文件的蛋疼问题...初学hibernate,映射文件都是用hibernate tool生成的,请问究竟是什
求助!hibernate的映射文件的蛋疼问题...
初学hibernate,映射文件都是用hibernate tool生成的,请问究竟是什么问题?
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [E:\My Code\j2ee\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\DigitalFamily\WEB-INF\classes\config\spring-applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from file E:\My Code\j2ee\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Test\WEB-INF\classes\com\test\model\security\Authority.hbm.xml
hibernate exception
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2013-1-16 22:46:12 by Hibernate Tools 3.4.0.CR1 -->
<hibernate-mapping>
<class name="com.test.model.security.Authority" table="DF_AUTHORITY">
<id name="id" type="int">
<column name="[ID]" />
<generator class="identity" />
</id>
<property name="name" type="java.lang.String">
<column name="[NAME]" />
</property>
<property name="desc" type="java.lang.String">
<column name="[DESC]" />
</property>
<property name="status" type="int">
<column name="[STATUS]" />
</property>
<set name="resources" table="RESOURE" inverse="false" lazy="true">
<key>
<column name="[RESOURCE_ID]" />
</key>
<one-to-many class="com.test.model.security.Resoure" />
</set>
</class>
</hibernate-mapping>
[解决办法]
你这是创建sessionFactory失败。
所以你发hmb.xml感觉应该没用吧。。
你应该发的是hibernate.cfg.xml
[解决办法]
不能解析这个映射文件,[ID]类似这样的应该配成你对应表里的字段名。
------解决方案--------------------
你的这个文件有没有注入到hibernate.cfg.xml里面啊?
[解决办法]
<id name="id" type="int"> type应该要这样type="java.lang.Integer"
<column name="[STATUS]" /> 中的name值是表的字段,你的表中每个字段都有[]吗
[解决办法]
和Hibernate有毛关系,你初学Hibernate配什么Spring。
Spring用的是hibernate4的工厂类,Hibernate文件是3.0的头,当然报错。
[解决办法]
+1
它报的是 nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document
这个mapping document应该是指Authority.hbm.xml
无法解析估计就是因为header不对,找4.0的找不到
