org.hibernate.PropertyNotFoundException: Could not find a getter for employee in class com.itcast.f_hbm_oneToMany.Department
<hibernate-mapping package="com.itcast.f_hbm_oneToMany">
<class name="Department" table="department"> <!--generator主键生成策略 -->
<id name="id">
<generator class="native" />
</id>
<property name="name" />
<set name="employees">
<key column="departmentID"></key>
<one-to-many class="Employee"/>
</set>
</class>
</hibernate-mapping>
由于上面这个映射文件里我employees少写了s,造成了错误。映射文件里的属性是跟实体Department里的属性是一一对应的。实体Department如下:
public class Department {
private Integer id;
private String name;
private Set<Employee> employees = new HashSet<Employee>(); // 关联的很多员工
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Employee> getEmployees() {
return employees;
}
public void setEmployees(Set<Employee> employees) {
this.employees = employees;
}
@Override
public String toString() {
return "[Department: id=" + id + ", name=" + name + "]";
}
}
org.hibernate.PropertyNotFoundException: Could not find a getter for employee in class com.itcast.f_hbm_oneToMany.Department的更多相关文章
- org.hibernate.PropertyNotFoundException:could not find a getter for name in class ....
Hibernate创建持久化类须符合JavaBean的规范,"get","set"后面紧跟属性的名字,并且属性名的首字母为大写.如果不遵守这个规则,Hibern ...
- hibernate异常找不到get方法org.hibernate.PropertyNotFoundException: Could not find a getter for did in class com.javakc.hibernate.manytomany.entity.CourseEntity
属性的get方法没找到,可能是CourseEntity类中对应属性没有get方法,如果有就看CourseEntity.hbm.xml属性名称,应该是写错了不和CourseEntity类中属性名相同,修 ...
- 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.hibern ...
- SSH面试题(struts2+Spring+hibernate)
struts2 + Spring +hibernate Hibernate工作原理及为什么要用? 原理: 1.读取并解析配置文件 2.读取并解析映射信息,创建SessionFactory ...
- 【转】Hibernate 常见异常
转载地址:http://smartan.iteye.com/blog/1542137 Hibernate 常见异常net.sf.hibernate.MappingException 当出 ...
- Could not find a getter for orderItems in class
::, ERROR ContextLoader: - Context initialization failed org.springframework.beans.factory.BeanCreat ...
- Hibernate 常见异常
Hibernate 常见异常net.sf.hibernate.MappingException 当出现net.sf.hibernate.MappingException: Error r ...
- Hibernate常见错误整理
Hibernate常见错误合集 1.错误:object references an unsaved transient instance - save the transient instance ...
- Hibernate——hibernate的配置测试
Hibernate Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibernate可以自 ...
随机推荐
- UML类图几种关系总结
在UML类图中,常见的有以下几种关系: 泛化(Generalization), 实现(Realization),关联(Association),聚合(Aggregation),组合(Composit ...
- 安装node-sass
SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install node-sass
- L2-001. 紧急救援
L2-001. 紧急救援 题目链接:https://www.patest.cn/contests/gplt/L2-001 Dijstra 本题是dijstra的拓展,在求最短路的同时,增加了不同的最短 ...
- Arrays.toString(a)--->将数组a的值转换为字符串
Arrays.toString(数组)是java内置类Arrays类的一个方法,具体查Api可知.因为数组是不可直接输出的,它的作用是将数组转换为字符串.其实用for循环也是可以做到的,只不过比for ...
- hdu_5788_Level Up(树状数组+主席树)
题目链接:hdu_5788_Level Up 题意: 有一棵树,n个节点,每个节点有个能力值A[i],mid[i],mid的值为第i节点的子树的中位数(包括本身),现在让你将其中的一个节点的A值改为1 ...
- java.lang.SecurityException:Invalid signature file digest forManifest main attributes
今天在公司使用ant命令来从服务器中提取一个类的时候发现一个问题,每当我执行ant命令的时候就报如下异常: 想来想去猜测是Enovia提供的包没有做数字签名,但是如何解决这个问题呢?想不到解决方案只好 ...
- Ambari删除服务
ambari-cassandra-service上面推荐的方法: curl -u admin:$PASSWORD -i -H 'X-Requested-By: ambari' -X PUT -d '{ ...
- Storm常见问题处理
错误1:发布topologies到远程集群时,出现Nimbus host is not set异常.异常内容如下所示: [root@xop-dev-a bin]# ./storm jar /home/ ...
- idea代码调试debug篇
主要看图,看图一目了然. 断点的设定和eclipse一样,只要点一下就可以,下面是我设定的几个断点,再下面的三个窗口是用来调试代码的,这个和eclipse类似 调试常用的快捷键 F9 ...
- erlang 常用的计算长度函数
1.size 可以计算元祖长度和标准binary长度 2.tuple_size 计算元祖长度 3.length 计算列表长度 4.byte_size 计算标准和非标准binary的长度 非标准 < ...