JPA Query

민지킴·2021년 4월 14일
0

7. Collection Parameter

Let's consider the case when the where clause of our JPQL or SQL query contains the IN (or NOT IN) keyword:

SELECT u FROM User u WHERE u.name IN :names

In this case, we can define a query method that takes Collection as a parameter:

@Query(value = "SELECT u FROM User u WHERE u.name IN :names")
List<User> findUserByNameList(@Param("names") Collection<String> names);

As the parameter is a Collection, it can be used with List, HashSet, etc

profile
하루하루는 성실하게 인생 전체는 되는대로

0개의 댓글