org.hibernate.MappingException: An association from the table tuser refers to an unmapped c

        org.hibernate.MappingException: An association from the table tuser refers to an unmapped class: Role


  1. <hibernate-mapping>  
  2.     <class name="com.hbm.entity.User" table="tuser">  
  3.         <id name="userId">  
  4.             <column name="userId" />  
  5.             <generator class="sequence">  
  6.                 <param name="sequence">seq</param>  
  7.             </generator>  
  8.         </id>  
  9.         <property name="username"/>  
  10.         <property name="password"/>  
  11.           
  12.         <many-to-one name="role" column="roleId" class="com.hbm.entity.Role" unique="true" />  
  13.           
  14.     </class>  
  15. </hibernate-mapping>  

 

  1. <hibernate-mapping package="com.hbm.entity" >  
  2.     <class name="Role" >  
  3.        <id name="roleId" column="roleId" >  
  4.             <generator class="assigned"/>  
  5.        </id>  
  6.        <property name="name" />         
  7.     </class>         
  8. </hibernate-mapping>  

一对一单向外键关联 用户->角色

hibernate.cfg.xml 都加了对应的映射文件的

导致错误的原因是

<many-to-one name="role" column="roleId" class="com.hbm.entity.Role" unique="true" />

class 开始写的不是类的全路径

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值