Package io.github.perplexhub.rsql
Class RSQLJPASupport
java.lang.Object
io.github.perplexhub.rsql.RSQLCommonSupport
io.github.perplexhub.rsql.RSQLJPASupport
-
Constructor Summary
ConstructorsConstructorDescriptionRSQLJPASupport
(Map<String, jakarta.persistence.EntityManager> entityManagerMap) -
Method Summary
Modifier and TypeMethodDescriptionstatic long
count
(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, String rsqlQuery) Returns the number of instances that the givenSpecification
will return.static List<?>
findAll
(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, String rsqlQuery) Returns all entities matching the givenSpecification
.static List<?>
findAll
(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, String rsqlQuery, String sort) Returns all entities matching the givenSpecification
andSort
.static org.springframework.data.domain.Page<?>
findAll
(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, String rsqlQuery, org.springframework.data.domain.Pageable pageable) Returns aPage
of entities matching the givenSpecification
.static List<?>
findAll
(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, String rsqlQuery, org.springframework.data.domain.Sort sort) Returns all entities matching the givenSpecification
andSort
.static Optional<?>
findOne
(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, String rsqlQuery) Returns a single entity matching the givenSpecification
orOptional.empty()
if none found.protected String
static <T> org.springframework.data.jpa.domain.Specification<T>
static <T> org.springframework.data.jpa.domain.Specification<T>
static <T> org.springframework.data.jpa.domain.Specification<T>
static <T> org.springframework.data.jpa.domain.Specification<T>
rsql
(String rsqlQuery, List<RSQLCustomPredicate<?>> customPredicates) static <T> org.springframework.data.jpa.domain.Specification<T>
static <T> org.springframework.data.jpa.domain.Specification<T>
toSort
(SortSupport sortSupport) Add orderBy(s) toCriteriaQuery
.static <T> org.springframework.data.jpa.domain.Specification<T>
static <T> org.springframework.data.jpa.domain.Specification<T>
static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(QuerySupport querySupport) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, boolean distinct) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, boolean distinct, Map<String, String> propertyPathMapper) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, boolean distinct, Map<String, String> propertyPathMapper, List<RSQLCustomPredicate<?>> customPredicates, Map<String, jakarta.persistence.criteria.JoinType> joinHints) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, boolean distinct, Map<String, String> propertyPathMapper, List<RSQLCustomPredicate<?>> customPredicates, Map<String, jakarta.persistence.criteria.JoinType> joinHints, Map<Class<?>, List<String>> propertyWhitelist, Map<Class<?>, List<String>> propertyBlacklist) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, boolean distinct, Map<String, String> propertyPathMapper, Map<String, jakarta.persistence.criteria.JoinType> joinHints) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, List<RSQLCustomPredicate<?>> customPredicates) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, Map<String, String> propertyPathMapper) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, Map<String, String> propertyPathMapper, List<RSQLCustomPredicate<?>> customPredicates, Map<String, jakarta.persistence.criteria.JoinType> joinHints) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, Map<String, String> propertyPathMapper, List<RSQLCustomPredicate<?>> customPredicates, Map<String, jakarta.persistence.criteria.JoinType> joinHints, Map<Class<?>, List<String>> propertyWhitelist, Map<Class<?>, List<String>> propertyBlacklist) static <T> org.springframework.data.jpa.domain.Specification<T>
toSpecification
(String rsqlQuery, Map<String, String> propertyPathMapper, Map<String, jakarta.persistence.criteria.JoinType> joinHints) Methods inherited from class io.github.perplexhub.rsql.RSQLCommonSupport
addConverter, addConverter, addEntityAttributeParser, addEntityAttributeTypeMap, addMapping, addMapping, addPropertyBlacklist, addPropertyBlacklist, addPropertyWhitelist, addPropertyWhitelist, getConversionService, getEntityManagerMap, getManagedTypeMap, getPropertyBlacklist, getPropertyRemapping, getPropertyWhitelist, getValueTypeMap, init, removeConverter, toComplexMultiValueMap, toMultiValueMap
-
Constructor Details
-
RSQLJPASupport
public RSQLJPASupport() -
RSQLJPASupport
-
-
Method Details
-
rsql
-
rsql
public static <T> org.springframework.data.jpa.domain.Specification<T> rsql(String rsqlQuery, boolean distinct) -
rsql
-
rsql
-
rsql
public static <T> org.springframework.data.jpa.domain.Specification<T> rsql(String rsqlQuery, List<RSQLCustomPredicate<?>> customPredicates) -
toSpecification
public static <T> org.springframework.data.jpa.domain.Specification<T> toSpecification(String rsqlQuery) -
toSpecification
-
toSpecification
public static <T> org.springframework.data.jpa.domain.Specification<T> toSpecification(String rsqlQuery, boolean distinct) -
toSpecification
-
toSpecification
public static <T> org.springframework.data.jpa.domain.Specification<T> toSpecification(String rsqlQuery, List<RSQLCustomPredicate<?>> customPredicates) -
toSpecification
-
toSpecification
-
toSpecification
-
toSpecification
-
toSpecification
public static <T> org.springframework.data.jpa.domain.Specification<T> toSpecification(String rsqlQuery, Map<String, String> propertyPathMapper, List<RSQLCustomPredicate<?>> customPredicates, Map<String, jakarta.persistence.criteria.JoinType> joinHints, Map<Class<?>, List<String>> propertyWhitelist, Map<Class<?>, List<String>> propertyBlacklist) -
toSpecification
public static <T> org.springframework.data.jpa.domain.Specification<T> toSpecification(QuerySupport querySupport) -
toSpecification
public static <T> org.springframework.data.jpa.domain.Specification<T> toSpecification(String rsqlQuery, boolean distinct, Map<String, String> propertyPathMapper, List<RSQLCustomPredicate<?>> customPredicates, Map<String, jakarta.persistence.criteria.JoinType> joinHints, Map<Class<?>, List<String>> propertyWhitelist, Map<Class<?>, List<String>> propertyBlacklist) -
toSort
public static <T> org.springframework.data.jpa.domain.Specification<T> toSort(@Nullable String sortQuery) -
toSort
-
toSort
public static <T> org.springframework.data.jpa.domain.Specification<T> toSort(SortSupport sortSupport) Add orderBy(s) toCriteriaQuery
. Example:"field1,asc;field2,desc;field3.subfield1,asc"
- Type Parameters:
T
-- Parameters:
sortSupport
- - sort support- Returns:
Specification
with specified order by
-
findOne
public static Optional<?> findOne(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, @Nullable String rsqlQuery) Returns a single entity matching the givenSpecification
orOptional.empty()
if none found.- Parameters:
jpaSpecificationExecutor
- JPA repositoryrsqlQuery
- can be null.- Returns:
- never null.
- Throws:
org.springframework.dao.IncorrectResultSizeDataAccessException
- if more than one entity found.
-
findAll
public static List<?> findAll(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, @Nullable String rsqlQuery) Returns all entities matching the givenSpecification
.- Parameters:
jpaSpecificationExecutor
- JPA repositoryrsqlQuery
- can be null.- Returns:
- never null.
-
findAll
public static org.springframework.data.domain.Page<?> findAll(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, @Nullable String rsqlQuery, org.springframework.data.domain.Pageable pageable) Returns aPage
of entities matching the givenSpecification
.- Parameters:
jpaSpecificationExecutor
- JPA repositoryrsqlQuery
- can be null.pageable
- must not be null.- Returns:
- never null.
-
findAll
public static List<?> findAll(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, @Nullable String rsqlQuery, org.springframework.data.domain.Sort sort) Returns all entities matching the givenSpecification
andSort
.- Parameters:
jpaSpecificationExecutor
- JPA repositoryrsqlQuery
- can be null.sort
- must not be null.- Returns:
- never null.
-
findAll
public static List<?> findAll(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, @Nullable String rsqlQuery, @Nullable String sort) Returns all entities matching the givenSpecification
andSort
.- Parameters:
jpaSpecificationExecutor
- JPA repositoryrsqlQuery
- can be null.sort
- can be null, comma delimited.- Returns:
- never null.
-
count
public static long count(org.springframework.data.jpa.repository.JpaSpecificationExecutor<?> jpaSpecificationExecutor, @Nullable String rsqlQuery) Returns the number of instances that the givenSpecification
will return.- Parameters:
jpaSpecificationExecutor
- JPA repositoryrsqlQuery
- theSpecification
to count instances for. Can be null.- Returns:
- the number of instances.
-
getVersion
- Overrides:
getVersion
in classRSQLCommonSupport
-