cannot cast for User.DepartmentId....................

无法转换出错,原因是类与表名相互映射的映射文件中出错,其中的many-to-one属性,class类名错误
<!– 用户与部门多对一关系 –>
原先出错的配置:
<many-to-one name=”department”  class=”com.lnx.oa.domain.User”  column=”departmentId”></many-to-one>
修改后的正确配置:
<many-to-one name=”department”  class=”com.lnx.oa.domain.Department”  column=”departmentId”></many-to-one>

删除出错的原因,多对一需要添加级联删除属性delete,修改后的正确配置是:
<!– 用户与部门多对一关系 –>
<many-to-one name=”department”  class=”com.lnx.oa.domain.Department” cascade=”delete” column=”departmentId”></many-to-one>

    原文作者:喜欢LANG的鑫
    原文地址: https://blog.csdn.net/LUONIANXIN08/article/details/90298825
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞