What’s the difference between the IN and MEMBER OF JPQL operators?
What’s the difference between the IN and MEMBER OF JPQL operators?
Share
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.
IN tests is value of single valued path expression (persistent attribute of your entity) in values you provided to query (or fetched via subquery).
MEMBER OF tests is value you provided to query (or defined with expression) member of values in some collection in your entity.
Lets’s use following example entity:
And following test data:
With following query we get a1 as result, because it’s someValue is one of the (0,1,3). Using literals in query (SELECT a FROM EntityA a WHERE a.someValue IN (0, 1, 3)) produces same result.
With following query we get a2 as result, because 7 is one of the values in listOfValues:
This functionality (including collection as parameter) is defined in JPA 2.0 specification and is not specific to Hibernate (above code works for example with EclipseLink).