2 zmjmvp zmjmvp 于 2016.01.17 20:21 提问

关于hibernate的配置命名问题求解答

一直报org.hibernate.PropertyNotFoundException: Could not find a getter for name in class cn.zmj.bean.Service

我感觉我的命名并没有错

User.hbm.xml:

 <set name="service" cascade="all" lazy="true">
<key column="user"></key>
<one-to-many class="Service" />
</set>


<set name="manage" cascade="all" lazy="true">
<key column="manage"></key>
<one-to-many class="Service" />
</set>




User:


private Set<Service> service = new HashSet<Service>();
private Set<Service> manage = new HashSet<Service>();


public Set<Service> getService() {
return service;
}
public void setService(Set<Service> service) {
this.service = service;
}
public Set<Service> getManage() {
return manage;
}
public void setManage(Set<Service> manage) {
this.manage = manage;
}




Service.hbm.xml:


<many-to-one name="user" class="User" column="user"></many-to-one>


<many-to-one name="manage" class="User" column="manage"></many-to-one>


Service:


private User user;
private User manage;


public User getManage() {
return manage;
}
public void setManage(User manage) {
this.manage = manage;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}

2个回答

caozhy
caozhy   Ds   Rxr 2016.01.17 20:32
wojiushiwo945you
wojiushiwo945you   Ds   Rxr 2016.01.17 20:51

检查下这个class cn.zmj.bean.Service类中有没有name属性,name属性生成get/set方法了没有。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!