hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibernate.domain.Employee1错误

出现这种错误是因为,实体类的配置文件(ClassName.hbm.xml)中的属性名和类中的属性名不一致造成的,检查并修改就可解决

比如:

类有如下属性:

private int id;

private String name;
private Department department;

配置文件:

<class name="Employee1">

<id name="id">
            <generator class="native"/>
        </id>

<property name="name"/>
        <many-to-one name="depart" column="depart_id"/>
    </class>

///////////////////////////

如上就会出现错误,因为多对一关系中的name的值depart和类的属性department没对应,就报错了

hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibernate.domain.Employee1错误的更多相关文章

  1. org.hibernate.TypeMismatchException: Provided id of the wrong type for class cn.itcast.entity.User. Expected: class java.lang.String, got class java.lang.Integer at org.hibernate.event.internal.Defau

    出现org.hibernate.TypeMismatchException: Provided id of the wrong type for class cn.itcast.entity.User ...

  2. 报错:Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): cn.itcast.bos.domain.base.SubArea

    因为 实体类中的主键 是String类型 不能自动为其分配id  所以需要手动设置在service层   model.setId(UUID.randomUUID().toString());

  3. org.hibernate.AnnotationException: No identifier specified for entity: cn.itcast.domain.Counter

    因为我的hibernate映射表没有主键所以报这个错. 解决方案是: 1.创建一个主键 2.hibernate处理无主键的表的映射问题,其实很简单,就是把一条记录看成一个主键,即组合主键<com ...

  4. hibernate延迟加载org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.javakc.hibernate.onetomany.entity.DeptEntity.emp, could not initialize proxy - no Session

    public static void main(String[] args) {  DeptEntity dept = getDept("402882e762ae888d0162ae888e ...

  5. Hibernate从入门到上手(纯java project、Maven版本hibernate)

    Hibernate(orm框架)(开放源代码的对象关系映射框架) Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一 ...

  6. 报错HTTP Status 500 - HHH000142: Javassist Enhancement failed: cn.itcast.entity.Customer; nested exception is org.hibernate.HibernateException: HHH000142: Javassist Enhancement failed: cn.itcast.entity.

    报错 type Exception report message HHH000142: Javassist Enhancement failed: cn.itcast.entity.Customer; ...

  7. 报错HTTP Status 500 - The given object has a null identifier: cn.itcast.entity.Customer; nested exception is org.hibernate.TransientObjectException: The given object has a null identifier:

    在使用模型驱动封装的时候,要保证表单中name属性名和类中属性名一致,否则将会报错如下: HTTP Status 500 - The given object has a null identifie ...

  8. HTTP Status 500 - javax.el.PropertyNotFoundException: Property 'lkmId' not found on type cn.itcast.entity.LinkMan

    报错 type Exception report message javax.el.PropertyNotFoundException: Property 'lkmId' not found on t ...

  9. ERROR org.hibernate.internal.SessionImpl - HHH000346: Error during managed flush [object references an unsaved transient instance - save the transient instance before flushing: cn.itcast.domain.Custom

    本片博文整理关于Hibernate中级联策略cascade和它导致的异常: Exception in thread "main" org.hibernate.TransientOb ...

随机推荐

  1. git常见操作总结

    git config --global user.name "liyang"git config --global user.email "liyangslj@126.c ...

  2. BZOJ【1606】购买干草

    1606: [Usaco2008 Dec]Hay For Sale 购买干草 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 859  Solved: 63 ...

  3. iptables介绍iptables和netfilter

    随着互联网技术的方兴未艾,各种网络应用层出不穷,网络攻击.黑客入侵也成了网民畅游互联网的心头大患,互联网安全也愈加受到了人们的重视.网络防火墙,作为一种简单高效的互联网防御手段,逐渐成为了网民畅游网络 ...

  4. ASP.NET MVC 实现 AJAX 跨域请求

    ASP.NET MVC 实现AJAX跨域请求的两种方法 和大家分享下Ajax 跨域的经验,之前也找了好多资料,但是都不行,后来看到个可行的修改了并测试下 果然OK了   希望对大家有所帮助! 通常发送 ...

  5. web前端生成图片之探索踩坑

    前段时间,产品和运营整了个非常变态的需求,要求将一个活动页面输出为图片,然后用户进行分享 开始以为是用户自己手动截图分享,没想到后来不是,细思极恐,感叹需求之变态. 从网上找了N个方案,最后确定使用  ...

  6. 分享Kali Linux 2017.1镜像

     分享Kali Linux 2017.1镜像 Kali Linux官方于4月24日发布Kali Linux 2017.1版本.该版本仍然采用滚动更新方式,所以软件源为kali-rolling.至现在分 ...

  7. Codeforces Round #298 (Div. 2) A、B、C题

    题目链接:Codeforces Round #298 (Div. 2) A. Exam An exam for n students will take place in a long and nar ...

  8. PHP的按位运算符是什么意思

    按位运算符是什么意思? 按位运算符(Bitwise Operators)是用于对涉及单个位操作的位模式或二进制数字执行位操作的运算符. 按位运算符可以用于: 1.通信堆栈,其中标头中的各个位附加到数据 ...

  9. Maven在[INFO] Generating project in Interactive mode卡住的问题解决

    我的环境: Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T00:41:47+08:00) Maven ...

  10. Android Retrofit使用教程

    Square公司开源了许多优秀的库,Retrofit就是其中之一. Retrofit是用来简化APP访问服务器API,如果你的服务器使用的使RESTAPI,那么赶紧使用Retrofit吧. 官方的文档 ...