我现在建了一个User 一个Email 是一个一对多的关联关系,查询User的时候直接用getEmail方法得到当前登录User的所有Email的Set集合,但是我现在要添加删除邮件的功能,所以加了一个removed字段,removed是false的时候代表没有删除的Email,removed是true的时候是垃圾箱的Email,所以我现在要在查询的Email上加removed的限制条件,怎么加啊!求高手啊!在线等啊!用的是hibernatetemplate
调试欢乐多
public String execute() throws Exception {
int userid = (Integer)ServletActionContext.getRequest().getSession().getAttribute("userid");
this.user = this.service.getCurrentUser(userid);
ServletActionContext.getRequest().setAttribute("emails",this.user.getEmails());
return SUCCESS;
}
我现在能得到登录用户下的所有email,ServletActionContext.getRequest().setAttribute("emails",this.user.getEmails());是发到页面上去,但这是所有email,我想加removed条件
* 得到当前登录的用户
*/
@Override
public User getCurrentUser(int id){
return (User)this.getHibernateTemplate().get(User.class, id);
}
那你改变你的pojo对象状态不就得了