hibernate出现 org.hibernate.PropertyNotFoundException: field [departmen] not found on cn.itcast.hibernate.domain.Employee1错误
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错误的更多相关文章
- 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 ...
- 报错: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());
- org.hibernate.AnnotationException: No identifier specified for entity: cn.itcast.domain.Counter
因为我的hibernate映射表没有主键所以报这个错. 解决方案是: 1.创建一个主键 2.hibernate处理无主键的表的映射问题,其实很简单,就是把一条记录看成一个主键,即组合主键<com ...
- 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 ...
- Hibernate从入门到上手(纯java project、Maven版本hibernate)
Hibernate(orm框架)(开放源代码的对象关系映射框架) Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一 ...
- 报错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; ...
- 报错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 ...
- 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 ...
- 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 ...
随机推荐
- linux之eval
1. eval command-line 其中command-line是在终端上键入的一条普通命令行.然而当在它前面放上eval时,其结果是shell在执行命令行之前扫描它两次.如: pipe=&qu ...
- ubuntu 忘记密码,忘记root密码的解决办法
ubuntu的root默认是禁止使用的,在安装的时候也没有要求设置root的密码.要使用,给root设置密码就行了,sudo passwd root .如果只是普通用户密码忘了,用root就可以修改. ...
- iPhone屏幕旋转
iPhone屏幕内容旋转 在iOS6之前的版本中,通常使用 shouldAutorotateToInterfaceOrientation 来单独控制某个UIViewController的方向,需要哪个 ...
- soap1.1与soap1.2区别
- 《Linux命令行与shell脚本编程大全 第3版》Linux命令行---21
以下为阅读<Linux命令行与shell脚本编程大全 第3版>的读书笔记,为了方便记录,特地与书的内容保持同步,特意做成一节一次随笔,特记录如下:
- 02深入理解C指针之---指针类型和值
该系列文章源于<深入理解C指针>的阅读与理解,由于本人的见识和知识的欠缺可能有误,还望大家批评指教. 1.指针的类型: 可以在声明指针时,指定指针的类型,例如: (1)void *x 声 ...
- EBImage - - 给图片增加字符
EBImage中文文档 英文版出处:http://www.bioconductor.org/packages/release/bioc/vignettes/EBImage/inst/doc/EBIma ...
- [MySQL] lock知识梳理
MySQL Lock机制 INDEX: MySQL事务隔离级别 MVCC MySQL Lock类型 MySQL MDL CONTENT: 1. MySQL事务隔离级别 Read Uncommit RU ...
- hdu 2685(数论相关定理+欧几里德定理+快速取模)
I won't tell you this is about number theory Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- Java IO 学习(四)BIO/NIO
本文会尝试介绍Java中BIO与NIO的范例与原理 使用的模型非常简单:服务器--客户端模型,服务器会将客户端发送的字符串原样发回来.也就是所谓的echo server. BIO 也就是所谓的Sock ...