I'm facing issues when passing specification to the repository.findAll()
Version:spring-boot-starter-data-jpa-2.2.4.RELEASE
Repository
@Repository
public interface ServerAttributesRepository extends JpaRepository<ServerAttributes, Integer>{
public ServerAttributes findById(int Id);
}
and when I call repository.findAll
by passing specification, I get error
ServerAttributeSpecification spec1 = new ServerAttributeSpecification(
new SearchCriteria("server", SearchOperation.EQUALITY, "1"));
List<ServerAttributes> serverAttributesList = serverAttributesRepository.findAll(spec1);
Error:
Cannot resolve method 'findAll(com.cloud.compareService.specification.ServerAttributeSpecification)'
and I can not find findAll(Specification<T> spec)
in my JpaRepository
reference: https://www.baeldung.com/rest-api-query-search-language-more-operations
You need to extend JpaSpecificationExecutor
interface to get support for Specifications, so try:
@Repository
public interface ServerAttributesRepository extends JpaRepository<ServerAttributes, Integer>, JpaSpecificationExecutor<ServerAttributes> {
public ServerAttributes findById(int Id);
}