我正在尝试编写一个搜索,使用Hibernate对两种类型的vatiables运行搜索,我有一个模型客户,它具有属性: Id、名称、用户名、密码、类型为String和int。我创建了"customerlDao“和"customerDaoImpl".现将其说明如下。
公共接口CustomerDao {
public Customer validateUser(String username, String password);
}
@Override
public Customer validateUser(String username, String password) {
Criteria criteria = getSession().createCriteria(Customer.class);
Customer customer = (Customer) criteria.add(Restrictions.eq(username, password)).uniqueResult();
return customer;
}
但是,这不管用。错误信息“无法解析属性:<”用户名“> of: com.education.library.model.Customer”如何更改它。
发布于 2015-11-11 08:14:36
Restrictions.eq(username, password)
有一个问题。你需要两个限制
Restrictions.eq('username', username)
和Restrictions.eq('password', password)
.
而且您可能有一个不正确的客户映射。请也给我看看。
https://stackoverflow.com/questions/33644378
复制相似问题