O'Reilly logo

Spring Data by Petri Kainulainen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding custom functionality to all repositories

Sometimes we have to add custom functionality to all repositories. In this section, we will learn how we can do this and create a custom repository method that is used to delete an entity by using its ID.

We can add custom functionality to all repositories by following these steps:

  1. Create a base interface that declares the custom methods.
  2. Implement the created interface.
  3. Create a repository factory bean.
  4. Configure Spring Data JPA to use our repository factory bean.
  5. Create a repository interface.
  6. Implement a service class that uses the custom functionality.

Creating the base repository interface

We start by creating a base repository interface that declares the methods that are available in the actual repositories. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required