单个JPQL查询或多个组合输入的条件

时间:2017-07-12 05:23:32

标签: hibernate jpa java-ee

我使用下面的JPQL查询来检查学生是否存在名称和id组合。

select id from student where name='name' and id=1

现在我需要一次检查1000个组合。 运行相同的查询1000次是性能威胁。 我不确定我们是否可以用1000组合进行单一查询。 这1000个组合来自UI,因此无法加入。 我们能用JPQL / Criteria实现这个目标吗? (没有临时表/ plsql)

1 个答案:

答案 0 :(得分:0)

我认为没有性能问题就无法做到这一点,但是,您可以使用union all statment来改进它,例如:

select id from student where name='name' and id=1 union all select id from student where name='name2' and id=2
相关问题