码迷,mamicode.com
首页 > Web开发 > 详细

org.hibernate.PropertyNotFoundException: Could not find a getter for employee in class com.itcast.f_hbm_oneToMany.Department

时间:2016-10-24 01:48:13      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:string   name   net   ble   column   log   --   文件   map   

<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

标签:string   name   net   ble   column   log   --   文件   map   

原文地址:http://www.cnblogs.com/johnsonwei/p/5991497.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!