Spring Data IN clause adds extra parentheses

I have a Role table with a name column. I need to get all roles whose names are either "role1" or "role2". The role repository method is as follows:

Set<Role> findByNameIsIn(Set<String> roleNames);

My database contains only "role1". The generated query is as follows:

SELECT ID, NAME FROM ROLE WHERE (NAME IN ((?,?)))
    bind => [role1, role2]

Note the double brackets around the options. The result set is empty. When I try to execute this request manually through the h2 console, there are no results either. The following query is executed:

SELECT ID, NAME FROM ROLE WHERE (NAME IN ('role1', 'role2'))

My set contains two elements. Sets should be supported as a parameter type. See: https://dzone.com/refcardz/core-spring-data

And finally the question: what am I missing?

+4
1

- EclipseLink ( , ). 2011 !.. :

@Query("select r from Role r  where r.name in ?1")
Set<Role> findByNameIsIn(Set<String> roleNames);

:

SELECT ID, NAME FROM ROLE WHERE (NAME IN (?,?))
    bind => [role1, role2] 
+6

All Articles