org.hibernate.PropertyAccessException: Exception occurred inside getter of ******——【hibernate 日常錯誤】

En:org.hibernate.PropertyAccessException: Exception occurred inside getter of org.enva.pojo.Person.password

錯誤原因:Person 實體類中的password屬性的setting/getting方法同password的類型不匹配  以下便是錯誤示例:【錯誤位置由紅色標出】

package org.enva.pojo;

import java.util.Date;
/**
 * 持久化類設計
 * 注意:
 *     持久化類通常建議有一個持久化標識符(ID)
 *  持久化標識符通常建議使用 封裝類(基本類型有默認值)
 *  持久化類通常建議手動給定一個無參構造器(因爲有一些操作,是反射進行的)
 *  屬性通常建議提供 getting/setting方法
 *  持久化類不能是final
 *  持久化類中如果使用了集合類型數據,只能用接口類型進行申明(List/Set/Map)
 *  List list=new ArrayList();
 * @author Administrator
 * @file Person.java
 * @date 2015年12月3日
 * @action
 */
public class Person {
    private Integer id;
    private String name;
    private Integer password;
    private Date birthday;
    public Person(){}
    public Person(String name, int password, Date birthday) {
        super();
        this.name = name;
        this.password = password;
        this.birthday = birthday;
    }
    @Override
    public String toString() {
        return "Person [id=" + id + ", name=" + name + ", password=" + password + ", birthday=" + birthday + "]";
    }
    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 int getPassword() {
        return password;
    }
    public void setPassword(int password) {
        this.password = password;
    }

    public Date getBirthday() {
        return birthday;
    }
    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }
}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章