Package it.tidalwave.util.spring.jpa
Class JpaSpecificationFinder<M,E,F extends it.tidalwave.util.Finder<M>,R extends org.springframework.data.jpa.repository.JpaSpecificationExecutor<E>>
java.lang.Object
it.tidalwave.util.spi.HierarchicFinderSupport<M,F>
it.tidalwave.util.spring.jpa.JpaSpecificationFinder<M,E,F,R>
- Type Parameters:
M
- the static type of the model objectE
- the static type of the JPA entityF
- the static type of theFinder
R
- the static type of the repository
- All Implemented Interfaces:
it.tidalwave.util.Finder<M>
,Serializable
,Cloneable
public class JpaSpecificationFinder<M,E,F extends it.tidalwave.util.Finder<M>,R extends org.springframework.data.jpa.repository.JpaSpecificationExecutor<E>>
extends it.tidalwave.util.spi.HierarchicFinderSupport<M,F>
A
Finder
that works with a repository extending JpaSpecificationExecutor
.- Author:
- Fabrizio Giudici
- See Also:
- Stereotype:
- Finder
-
Nested Class Summary
Nested classes/interfaces inherited from interface it.tidalwave.util.Finder
it.tidalwave.util.Finder.InMemorySortCriterion<U extends Object>, it.tidalwave.util.Finder.SortCriterion, it.tidalwave.util.Finder.SortDirection
-
Field Summary
Modifier and TypeFieldDescriptionprotected final R
protected final List<JpaSpecificationFinder.JpaSorter>
Fields inherited from class it.tidalwave.util.spi.HierarchicFinderSupport
firstResult, maxResults
-
Constructor Summary
ConstructorDescriptionJpaSpecificationFinder
(JpaSpecificationFinder<M, E, F, R> other, Object override) The required constructor for subclasses ofHierarchicFinderSupport
.JpaSpecificationFinder
(R repository, Function<E, M> entityToModel) Creates a new instance given a repository and a model-to-entity transformer. -
Method Summary
Modifier and TypeMethodDescriptionstatic it.tidalwave.util.Finder.SortCriterion
Creates aFinder.SortCriterion
by key.protected void
composeSpecification
(jakarta.persistence.criteria.Root<E> root, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, List<? super jakarta.persistence.criteria.Predicate> predicates) protected org.springframework.data.jpa.domain.Specification<E>
sort
(it.tidalwave.util.Finder.SortCriterion criterion, it.tidalwave.util.Finder.SortDirection direction) Methods inherited from class it.tidalwave.util.spi.HierarchicFinderSupport
clone, clone, clonedWith, computeResults, count, from, getContexts, getSource, max, ofType, results, sort, toString, withContext
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface it.tidalwave.util.Finder
firstResult, forEach, from, from, iterator, max, max, optionalFirstResult, optionalResult, result, stream
-
Field Details
-
repository
-
entityToModel
-
sorters
-
-
Constructor Details
-
JpaSpecificationFinder
Creates a new instance given a repository and a model-to-entity transformer.- Parameters:
repository
- the repositoryentityToModel
- the transformer
-
JpaSpecificationFinder
public JpaSpecificationFinder(@Nonnull JpaSpecificationFinder<M, E, F, R> other, @Nonnull Object override) The required constructor for subclasses ofHierarchicFinderSupport
.
-
-
Method Details
-
sort
@Nonnull public F sort(@Nonnull it.tidalwave.util.Finder.SortCriterion criterion, @Nonnull it.tidalwave.util.Finder.SortDirection direction) -
by
Creates aFinder.SortCriterion
by key.- Parameters:
sortingKey
- the key- Returns:
- the
SortCriterion
-
computeNeededResults
-
getSpecification
-
composeSpecification
-