Is there any way to perform a query like the following using JPA2 criteria APIs?
select a from b where a in (1, 2, 3, 4)
There’s a way to do that using plain Hibernate, but we can’t find anything like that in JPA2.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes JPA 2 Critera supports returning a specific field from a entity and using a where clause which includes an
inclause. I have included an example below which takes a JPQL and converts it to a similar JPA 2 Criteria-based option.JPQL:
Criteria:
Here are some links that give some addition examples of using
in:Hope this helps!