Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Spring Data

You're reading from  Spring Data

Product type Book
Published in Nov 2012
Publisher Packt
ISBN-13 9781849519045
Pages 160 pages
Edition 1st Edition
Languages
Author (1):
Petri Kainulainen Petri Kainulainen
Profile icon Petri Kainulainen
Toc

Adding custom functionality to a single repository


The ability to add custom functionality to a single repository is a useful feature when the added functionality is related only to a single entity. In this section, we will investigate how this can be done, and move the pagination and search logic from the service layer to the repository layer.

If we want to add custom functionality to a single repository, we have to follow the following steps:

  1. Create a custom interface that declares the custom methods.

  2. Implement the created interface.

  3. Create a repository interface.

  4. Create a service implementation that uses the custom functionality.

Creating the custom interface

Our first step is to create an interface that declares the custom repository methods. Since our goal is to move the pagination and search logic to the repository layer, we have to add the following methods to the created interface:

Method

Description

List<Contact> findAllForPage(int pageIndex, int pageSize)

Returns all contacts...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime}