首页 新闻 会员 周边 捐助

org.hibernate.MappingException: Unknown entity: from modle.Account

0
[已解决问题] 解决于 2018-07-24 11:31

在进行ssh整合时,利用MyEclipse自动导入hibernate等框架,结果是登陆效验不了,报错为org.hibernate.MappingException: Unknown entity: from modle.Account,可是我查看了后,发现都有啊,怎么解决?急急急,在线等

 

hibernate.cfg.xml里面

<mapping resource="modle/Account.hbm.xml" />
<mapping resource="modle/Leaveword.hbm.xml" />
<mapping resource="modle/Manager.hbm.xml" />
<mapping resource="modle/News.hbm.xml" />
<mapping resource="modle/Personinfo.hbm.xml" />
<mapping resource="modle/Tradeinfo.hbm.xml" />

问题补充:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="modle.Account" table="account" catalog="banksystem">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="native" />
</id>
<many-to-one name="personinfo" class="modle.Personinfo" fetch="select">
<column name="pid" not-null="true">
<comment>个人信息id</comment>
</column>
</many-to-one>
<property name="username" type="java.lang.String">
<column name="username" length="20" not-null="true">
<comment>账户名</comment>
</column>
</property>
<property name="userpwd" type="java.lang.String">
<column name="userpwd" length="20" not-null="true">
<comment>账户密码</comment>
</column>
</property>
<property name="balances" type="java.lang.Double">
<column name="balances" precision="10" not-null="true">
<comment>账户余额</comment>
</column>
</property>
<property name="status" type="java.lang.String">
<column name="status" length="8" not-null="true">
<comment>账户状态</comment>
</column>
</property>
<property name="openbank" type="java.lang.String">
<column name="openbank" length="30" not-null="true">
<comment>开户行</comment>
</column>
</property>
<property name="opendate" type="java.util.Date">
<column name="opendate" length="10" not-null="true">
<comment>开户日期</comment>
</column>
</property>
<set name="tradeinfosForSelfid" inverse="true">
<key>
<column name="selfid" not-null="true">
<comment>自己账号</comment>
</column>
</key>
<one-to-many class="modle.Tradeinfo" />
</set>
<set name="tradeinfosForOtherid" inverse="true">
<key>
<column name="otherid" not-null="true">
<comment>对方账号</comment>
</column>
</key>
<one-to-many class="modle.Tradeinfo" />
</set>
<set name="leavewords" inverse="true">
<key>
<column name="accid" not-null="true">
<comment>账号id</comment>
</column>
</key>
<one-to-many class="modle.Leaveword" />
</set>
</class>
</hibernate-mapping>

ZHANG-SL的主页 ZHANG-SL | 菜鸟二级 | 园豆:202
提问于:2015-05-18 08:22
< >
分享
最佳答案
0

所有类似name="modle.Account" 写错,应该直接写类名name="Account“加个命名空间 namespace="modle"

奖励园豆:5
李永京 | 老鸟四级 |园豆:3114 | 2015-05-18 09:49

你说的错误我改了 不过class标签没有namespace属性啊   问题依然存在

org.hibernate.MappingException: Unknown entity: from model.Account

 

hibernate.cfg.xml文件

<?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">

<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>

<session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://127.0.0.1:3306/
</property>
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">mysql</property>
<mapping resource="model/Manager.hbm.xml" />
<mapping resource="model/Tradeinfo.hbm.xml" />
<mapping resource="model/Account.hbm.xml" />
<mapping resource="model/News.hbm.xml" />
<mapping resource="model/Leaveword.hbm.xml" />
<mapping resource="model/Personinfo.hbm.xml" />

</session-factory>

</hibernate-configuration>

Account.hbm.xml文件

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
<class name="model.Account" table="account" catalog="banksystem">
<id name="id" type="java.lang.Integer">
<column name="id" />
<generator class="native" />
</id>
<many-to-one name="personinfo" class="model.Personinfo" fetch="select">
<column name="pid" not-null="true">
<comment>个人信息id</comment>
</column>
</many-to-one>
<property name="username" type="java.lang.String">
<column name="username" length="20" not-null="true">
<comment>账户名</comment>
</column>
</property>
<property name="userpwd" type="java.lang.String">
<column name="userpwd" length="20" not-null="true">
<comment>账户密码</comment>
</column>
</property>
<property name="balances" type="java.lang.Double">
<column name="balances" precision="10" not-null="true">
<comment>账户余额</comment>
</column>
</property>
<property name="status" type="java.lang.String">
<column name="status" length="8" not-null="true">
<comment>账户状态</comment>
</column>
</property>
<property name="openbank" type="java.lang.String">
<column name="openbank" length="30" not-null="true">
<comment>开户行</comment>
</column>
</property>
<property name="opendate" type="java.util.Date">
<column name="opendate" length="10" not-null="true">
<comment>开户日期</comment>
</column>
</property>
<set name="tradeinfosForSelfid" inverse="true">
<key>
<column name="selfid" not-null="true">
<comment>自己账号</comment>
</column>
</key>
<one-to-many class="model.Tradeinfo" />
</set>
<set name="tradeinfosForOtherid" inverse="true">
<key>
<column name="otherid" not-null="true">
<comment>对方账号</comment>
</column>
</key>
<one-to-many class="model.Tradeinfo" />
</set>
<set name="leavewords" inverse="true">
<key>
<column name="accid" not-null="true">
<comment>账号id</comment>
</column>
</key>
<one-to-many class="model.Leaveword" />
</set>
</class>
</hibernate-mapping>

ZHANG-SL | 园豆:202 (菜鸟二级) | 2015-05-18 10:22

@zhang001791: 在<hibernate-mapping> 上

李永京 | 园豆:3114 (老鸟四级) | 2015-05-18 11:31
其他回答(1)
0

如果方便的话,建议将Account.hbm.xml中的配置贴出来

dudu | 园豆:30939 (高人七级) | 2015-05-18 09:22

问题已补充

支持(0) 反对(0) ZHANG-SL | 园豆:202 (菜鸟二级) | 2015-05-18 09:39
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册