Custom Repositories
Repositores can be extended with custom code. This requires the following classes:
Spring repository interface
Custom repository interface
Custom repository implementation
Model
Repository Interface
public interface EntityCustomRepository {
public Iterable<Entity> findByCustomQuery();
}Custom Repository Interface
public interface EntityRepository extends JpaRepository<Entity, EntityKey> extends EntityCustomRepository {
}Custom Repository Implementation
Usage
Now calling the findByCustomQuery method in the repository will call the method in theDefautlEntityCustomRepository implementation. Spring will mix this code with the repository it generates.
Last updated
Was this helpful?