zoukankan      html  css  js  c++  java
  • 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 + "]";
        }
    
    }
  • 相关阅读:
    go语言最新版本 下载地址
    PHP5 各版本维护时间
    springzuul本地路由和跨服务器路由问题
    大数据学习路线(转载)
    springcoud feign超时的问题
    java 桥接模式
    springcloud单个服务内存使用详情
    centos7搭建filebeat
    centos7搭建logstash
    centos7搭建kibana
  • 原文地址:https://www.cnblogs.com/johnsonwei/p/5991497.html
Copyright © 2011-2022 走看看