hibernate的限制。用和,怎么用?

我有下面的表格

id, employee_no, survey_no, name 1 test 1 test_name 2 test2 1 test_name2 3 test3 1 test_name3 4 test4 2 test_name4 

如何通过将下面的AND组合成一个IN语句来使用Restriction.in进行查询?

  IN[ (if(survey_no==1) && employee_no== 'test') , (if(survey_no==1) && employee_no== 'test2') , ... ] 

我认为这是你想要使用的标准组合(顺便说一句。它更容易帮助Hibernate实体bean定义而不是表结构):

 String[] employeeNames = { "test", "test2" }; List surveys = getSession().createCriteria(Survey.class).add( Restrictions.and ( Restrictions.eq("surveyNumber", 1), Restrictions.in("employeeName", employeeNames) ) ).list(); 
 List employeeSurvey = getSession().createCriteria (EmployeeSurvey.class).add( Restrictions.and ( Restrictions.eq("survey_no", 1), Restrictions.in("employee_name", new String[] {"test", "test1"}) )).list();