0

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

enter image description here

reference: https://www.baeldung.com/rest-api-query-search-language-more-operations

1
  • 1
    Please don't include screenshots of code. Commented Sep 28, 2020 at 1:57

1 Answer 1

1

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);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.