hibernate4出现错误org.hibernate.QueryException: could not resolve property

org.hibernate.QueryException: could not resolve property

这个错误通常是因为我们配置字段的时候发生错误了

如以下代码,实体字段gid,如果你定义成了其他名字,而数据库字段是gid的话

那么可能就会发生的错误

private int gid;
@Column(name="gid",unique=false,nullable=false)
public int getGid() {
return gid;
}
public void setGid(int gid) {
this.gid = gid;
}

修改方法就是将属性字段改成与数据库字段一致的名字,并且修改get和set方法即可


爆款云服务器s6 2核4G 低至0.46/天,具体规则查看活动详情Blog Img