-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Spring Data Search allows to automatically expose endpoints in order to search for data related to JPA entities.
Spring Data Search provides an advanced search engine that does not require the creation of JPA repositories with custom methods needed to search on different fields of JPA entities.
We can search on any field, combine multiple criteria to refine the search, and even search on nested fields.
Spring Data Rest builds on top of the Spring Data repositories and automatically exports those as REST resources.
However, when we want to search for JPA entities according to different criteria, we need to define several methods in the Repositories to perform different searches.
Moreover, by default REST endpoints return JPA Entities content directly to the client, without mapping with a dedicated DTO class.
We can use Projections on Repositories, but this means that from the architecture level, we strongly associate the infrastructure layer with the application layer.
Spring Data Search allows to easily expose an endpoint for a JPA entity and thus be able to search on any fields of this entity, to combine several criteria and even search on fields belonging to sub-entities.
Let's say you manage Persons associated with Addresses, Vehicles and a Job.
You want to allow customers to search for them, regardless of the search criteria:
- Search for Persons whose first name is "John" or "Jane"
- Search for Persons whose company where they work is "Acme", and own a car or a motorbike
- Search for Persons who live in London
You could create a Repository with custom methods to perform all these searches, and you could add new custom methods according to the needs.
Alternatively, you can use Spring Data Search which allows you to perform all these searches with a minimum configuration, without the need of a custom Repository. If you want to do other different searches, you do not need to add new methods to do that.
Go to the Home Page.
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Nicolas Dos Santos - @Kobee1203
Project Link: https://github.com/Kobee1203/spring-data-search
Copyright (c) 2020 Nicolas Dos Santos and other contributors