JpaRepository vs CRUDRepository findAll
JpaRepository extends PagingAndSortingRepository
and PagingAndSortingRepository extends CrudRepository
.
This allows JpaRepository
to have a more specific return type of Itrable
which is List
The class CrudRepository
is part of the Spring Data Commons project and is the recommended interface to extend regardless of the actual data store used.
The reason CrudRepository
methods return Iterable
and not List
(or Set
) is because some data stores allow streaming of results and using a Collection
type would result in loss of functionality for such stores.