A common pattern is causing problems when the input lists grow large. Many Spring Data interfaces that extend org.springframework.data.jpa.repositoryJpaRepository
declare queries that use an in-clause. A simplified example:
@Query("SELECT c.someImportantData FROM SomeComponent c WHERE c.someForeignKeyId IN (:someIds)")
List<Object> getImportantDataBySomeIds(@Param("someIds") Collection<UUID> someIds);
This works great as long as the list of someIds
is small. With Postgresql
small is defined as 32767. However, several internal uses exceed this number and that causes errors/exceptions. Currently, those are fixed by partitioning the main list and then passing in smaller collections via the calling software. While this approach also works, I am wondering if there is a way within JPA/SpringDataJPA to accomplish the same? I am using Spring Data JPA 1.11.12 if that matters.