Use the findAll method from repository
repository.findAll()
Take a look here
Spring Data JPA API
Look here a small example that will fetch all MyObj objects that are stored
@Repository
public interface MyObjRepository extends JpaRepository<MyObj, Long> { }
@Service
public class MyService {
@Autowired
MyObjRepository repository;
public List<MyObj> findAllElements() {
return repository.findAll();
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…