2

When i change from crudrepository to pagingandsortingrepository there is no save method and the application begins to fail

      error: cannot find symbol
                courses.save(course);
                       ^
      symbol:   method save(Course)
      location: variable courses of type CourseRepository

I have tried extending both

2 Answers2

2

According to Interface PagingAndSortingRepository, there is no save method in this interface. Hence your code is failing.

But Interface CrudRepository has a save method.

Also, this hierarchy might help to clear the picture even more:

enter image description here

hiren
  • 1,067
  • 1
  • 9
  • 16
1

PagingAndSortingRepository repository has mainly been created for fetching records and not modify it.

In this case your repository interface can extend both PagingAndSortingRepository & CrudRepository

Ajit1789
  • 11
  • 2