【发布时间】:2020-10-19 20:11:08
【问题描述】:
我想创建这个 Spring Data 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);
}
服务:
@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"));
}
当我部署包时,我得到了这个错误:
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).
你知道如何解决这个问题吗?
【问题讨论】:
标签: java spring spring-data-jpa spring-data