Hibernate 无法解析属性:<&引用;用户名"&燃气轮机;共有:com.education.library.model.Customer
我正在尝试编写一个搜索,使用Hibernate在两种类型的梵蒂冈上运行搜索。我有一个模型客户,它具有以下属性:Id、名称、用户名、密码、类型为String和int。 我创建了“customerdao”和“customerDaoImpl”。下面给出了它们 公共接口客户道{Hibernate 无法解析属性:<&引用;用户名"&燃气轮机;共有:com.education.library.model.Customer,hibernate,dao,Hibernate,Dao,我正在尝试编写一个搜索,使用Hibernate在两种类型的梵蒂冈上运行搜索。我有一个模型客户,它具有以下属性:Id、名称、用户名、密码、类型为String和int。 我创建了“customerdao”和“customerDaoImpl”。下面给出了它们 公共接口客户道{ public Customer validateUser(String username, String password); } 但是,它不起作用,。错误消息“无法解析属性:of:com.education.library.
public Customer validateUser(String username, String password);
}
但是,它不起作用,。错误消息“无法解析属性:of:com.education.library.model.Customer”我如何更改它。限制有问题。eq(用户名、密码)。 你需要两个限制
Restrictions.eq('username',username)
和Restrictions.eq('password',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;
}