Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/apulbere/pet-shop-crop


https://github.com/apulbere/pet-shop-crop

Last synced: about 1 month ago
JSON representation

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();
}
```