关于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个回答

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

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐