Spring Data Repositories
- A Repository has methods for retrieving domain objects should delegate to a specialised Repository object such that alternative storage implementations may be interchanged.
- This is important. It allows you to easily substitute the persistence layer.
- i.e. going from SQL to NoSQL
Spring Data JPA
- Spring Data JPA is part of a larger family of Spring Data projects
- Uses Hibernate for persistence to supported RDBS system (About any major relational database)
- Spring Data JPA provides the implementation at run time (No SQL Required)
How to use Spring Data JPA?
- You extend a Java Repository Interface
interface TodoRepository extends CrudRepository<Todo, Long> {
Todo findTodoById(Long id);
Todo save(Todo todo);
Todo findAll();
Todo deleteById();
}