与和休眠限制,如何使用?

Cometta:

我有下面的表格

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();

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章