I want to create this Spring Data Repository:
Repository:
@Repository
public interface CustomersRepository extends JpaRepository<Users, Integer>, JpaSpecificationExecutor<Users> {
Page<Users> findAllByTypeIn(Pageable page, String... types);
Page<Users> findAllByTypeIn(Specification<Users> specification, Pageable pageable, List<String> types);
}
Service:
@Override
public Page<Users> findAll(int page, int size) {
return dao.findAllByTypeIn(PageRequest.of(page, size), "CustomerUser");
}
@Override
public Page<Users> getAllBySpecification(Specification<Users> specification, Pageable pageable) {
return this.dao.findAllByTypeIn(specification, pageable, List.of("CustomerUser"));
}
When I deploy the package I get this error:
Caused by: java.lang.IllegalStateException: Operator IN on type requires a Collection argument, found interface org.springframework.data.jpa.domain.Specification in method public abstract org.springframework.data.domain.Page org.engine.plugin.production.service.CustomersRepository.findAllByTypeIn(org.springframework.data.jpa.domain.Specification,org.springframework.data.domain.Pageable,java.util.List).
Do you know how this issue can be fixed?