Spring Data repository with empty IN clause.

The problem I’ve stabled upon started with a [spring data repository] (https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.core-concepts) like this: public interface SampleRepository extends CrudRepository<Sample, Integer>{ @Query("select s from Sample s where s.id in :ids") List<Sample> queryIn(@Param("ids") List<Integer> ids); } Actual query was of course more complicated that this. Complex enough to justify not using a [query method] (https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods). The problem emerges when you run this method with an empty collection as argument: repository.queryIn(Collections.emptyList()); The result is database dependent. [Read More]