1
@RepositoryRestResource
public interface EmployeeRepository extends JpaRepository<Employee, Integer> {

    @Query("SELECT employee FROM Employee employee")
    List<Employee> getAll();

    Page<Employee> findAll(Example<Employee> employeeExample, Pageable pageable);

}

If I call :

.../api/employees/search/getAll it gives me the result of getAll method

However JpaRepository has same function but I am unable to call it:

.../api/employees/search/findAll

Fortunately, I was able to write a @Query method that have same functionality.

But now I need to call this method from QueryByExampleExecutor(JpaRepository extends this interface)

<S extends T> Page<S> findAll(Example<S> var1, Pageable var2);

I wrote some function to EmployeeRepository, in order to call it as rest endpoint.

Page<Employee> findAll(Example<Employee> employeeExample, Pageable pageable);

But I get the bellow error:

findAll(Example, Pageable)' in 'com.foo.repository.EmployeeRepository' clashes with 'findAll(Example, Pageable)' in 'org.springframework.data.repository.query.QueryByExampleExecutor'; both methods have same erasure, yet neither overrides the other

I can not write a @Query method that has same functionality with that method.

How can I call inherited repository methods as a Rest Enpoint in Spring-Data ?

Muhammed Ozdogan
  • 5,341
  • 8
  • 32
  • 53
  • could be a duplicate of https://stackoverflow.com/questions/25201306/implementing-custom-methods-of-spring-data-repository-and-exposing-them-through https://stackoverflow.com/questions/21116539/custom-jpa-repository-method-published-by-spring-data-rest – rohitpal Sep 13 '19 at 08:55
  • No, I just asked how can I call inherited methods as rest endpoint from Spring Jpa, there is no custom method implementation. – Muhammed Ozdogan Sep 13 '19 at 09:00

1 Answers1

0

Correct signature is,

@Override
<S extends Employee> Page<S> findAll(Example<S> example, Pageable pageable)
Adisesha
  • 5,200
  • 1
  • 32
  • 43