hibernate 中配置问题 请大神指点一二

winner1014840718 2012-03-15 11:29:29
这是我的Student.hbm.xml
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-mapping package="com.bjsxt.hibernate.model">
<class name="Student" table="Student">
<id name="id" column="id" type="integer"></id>
<property name="name"></property>
<property name="age"></property>
</class>
</hibernate-mapping>

报错Exception in thread "main" org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/bjsxt/hibernate/model/Student.hbm.xml
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
Caused by: org.xml.sax.SAXParseException: Element type "hibernate-mapping" must be declared.
...全文
120 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ld191474639 2012-03-16
  • 打赏
  • 举报
回复
我的Student.hbm.xml
<?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.hibernate.Student" table="Student">
<id name="sid" column="ID_">
<generator class="native"/>
</id>
<property name="uname" />
<property name="age"/>


</class>



</hibernate-mapping>
dryZeng 2012-03-16
  • 打赏
  • 举报
回复
<property name="name"></property>
<property name="age"></property>

这两句没写column
ll894311655 2012-03-16
  • 打赏
  • 举报
回复
贴出你hiberenate的配置文件出来。。。。
math_sun 2012-03-16
  • 打赏
  • 举报
回复
是不是hibernate,cfg.xml中没有
<mapping resource="../Student.hbm.xml"/>
lp2012886 2012-03-16
  • 打赏
  • 举报
回复
是不是你的Student.hbm.xml文件和你的Student类里面的属性不匹配。。让eclipse无法解析通过。。。

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧