...

/

Custom Spring Data Repositories

Custom Spring Data Repositories

Learn how to create custom Spring Data repositories to add extra features of persistence.

At times, the default methods available through Spring Data repositories aren’t enough for our specific needs. In this case, we can choose to create custom Spring Data repositories with abstract methods.

The CustomCustomerRepository interface

First, let’s create a custom repository interface CustomCustomerRepository for the Customer entity with the findCustomerCustom abstract method.

Press + to interact
package com.smartdiscover.repository;
import com.smartdiscover.entity.Customer;
import org.springframework.stereotype.Repository;
@Repository
public interface CustomCustomerRepository {
Customer findCustomerCustom(String firstName, String lastName);
}
...