From the course: Creating Your First Spring Boot Microservice

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Declare Spring Data JPA repository interfaces

Declare Spring Data JPA repository interfaces

From the course: Creating Your First Spring Boot Microservice

Start my 1-month free trial

Declare Spring Data JPA repository interfaces

- Spring Data JPA is a game-changing framework where we get better functionality while writing less code. To use Spring Data JPA for a JPA entity, we declare a Java interface class that extends from CrudRepository, where T is the domain type the repository manages, and ID is the type of the ID of the entity the repository manages. So for a Tour we declare a TourRepository that extends from CrudRepository, then Spring Data JPA automatically provides the methods to create, read, update, and delete Tours. These are the provided methods to create or update a Tour in the database. These are the methods to delete Tours from the database. And finally we have various methods to look up Tours in the database. For the TourPackage entity, we see a TourPackageRepository that extends from CrudRepository. In this case the ID of the TourPackage is a string, so these are the default methods to create, read, and update, and delete a…

Contents