Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/apulbere/pet-shop-crop
https://github.com/apulbere/pet-shop-crop
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/apulbere/pet-shop-crop
- Owner: apulbere
- Created: 2024-01-21T09:38:06.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-01-21T19:14:14.000Z (12 months ago)
- Last Synced: 2024-01-21T20:55:28.694Z (12 months ago)
- Language: Java
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Demo project for [CriteriaOperator](https://github.com/apulbere/crop)
CriteriaOperator is a lightweight, zero dependency, and type-safe wrapper around Java Persistence Criteria API, which simplifies building queries, particularly useful within REST SQL (RSQL) context.
```java
@GetMapping("/pets")
List findAll(PetCriteriaOperator searchCriteria, CriteriaOperatorOrder order, CriteriaOperatorPage page) {
return cropService.create(Pet.class, searchCriteria, order, page)
.match(Pet_.id, PetCriteriaOperator::getId)
.match(Pet_.name, PetCriteriaOperator::getNickname)
.match(Pet_.birthdate, PetCriteriaOperator::getBirthdate)
.match(Pet_.price, PetCriteriaOperator::getPrice)
.join(Pet_.features)
.match(PetFeature_.feature, PetCriteriaOperator::getFeatures)
.endJoin()
.match(Pet_.active, PetCriteriaOperator::getActive)
.join(Pet_.petType)
.match(PetType_.code, PetCriteriaOperator::getType)
.join(PetType_.petCategory)
.match(PetCategory_.code, PetCriteriaOperator::getCategory)
.endJoin()
.endJoin()
.getResultList()
.stream()
.map(petMapper::map)
.toList();
}
```