@Entity
public class Employee{
private String Id;
private String preId;
}
I've a Entity like above and i want to get the search results on the combination of both fields. (preId+Id)
是否可以通过Restrictions eq方法验证上述字段组合与我的搜索输入值?
任何帮助将不胜感激......
答案 0 :(得分:0)
是的,你可以。您可以为Id和preId添加2个限制,如下所示。
public Employee getEmployee(Session session) {
Criteria crt = session.createCriteria(Employee.class);
crt.add(Restrictions.eq("Id", "1"));
crt.add(Restrictions.eq("preId", "123"));
return (Employee ) crt.uniqueResult();
}