Spring Data JPA – Get all elements

Tags: , ,

I’m new to Spring Data JPA and I want to ask if there is a method that can be used to fetch all items, not by a certain criterion. Any help would be helpful.


Use the findAll method from repository


Take a look here

Spring Data JPA API

Look here a small example that will fetch all MyObj objects that are stored

public interface MyObjRepository extends JpaRepository<MyObj, Long> { }

public class MyService {

MyObjRepository repository;

public List<MyObj> findAllElements() {
  return repository.findAll();


Source: stackoverflow