1
votes
@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 ?

1
No, I just asked how can I call inherited methods as rest endpoint from Spring Jpa, there is no custom method implementation.Muhammed Ozdogan

1 Answers

0
votes

Correct signature is,

@Override
<S extends Employee> Page<S> findAll(Example<S> example, Pageable pageable)