我有如下表
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<Survey> surveys = getSession().createCriteria(Survey.class).add(
Restrictions.and
(
Restrictions.eq("surveyNumber", 1),
Restrictions.in("employeeName", employeeNames)
)
).list();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)