From the course: Spring Data

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Spring Data CRUDRepository and JpaRepository

Spring Data CRUDRepository and JpaRepository - Spring Tutorial

From the course: Spring Data

Spring Data CRUDRepository and JpaRepository

- [Instructor] Now let's see how Spring Data JPA gives us better functionality while writing less code. In chapter one, we learned that Spring Data abstracts away from any particular data source by following a repository pattern. Now we're actually going to see the implementation of that pattern. Spring Data starts with a repository interface with two bounded type parameters. The first parameter, T, is the entity class name. The second parameter, ID, is the type of the unique ID of the entity. The repository interface is just a marker without any methods. Spring Data comments declares a CrudRepository interface. CrudRepository extends from repository and declares methods that create, update, read, and delete entities and inherit the bounded type parameters. List CrudRepository declares more methods that used list collections instead of iterables. JPA repositories extend from list CrudRepository, paging and sorting repository, and query by example executor and adds even more methods…

Contents