public class EmptyResultOnTypeMismatch<T> extends Object implements org.springframework.data.jpa.domain.Specification<T>
Wrapper that turns a Specification into a one that always produces in an empty result
(i.e. where 0 = 1) in case of a type mismatch (e.g. when type on path is Long
and the value from the HTTP parameter is not a numeric.
It's useful for polymorphic "OR" queries such as where id = ? or name = ?.
A spec will be wrapped with this decorator if onTypeMismatch property of @Spec
is explicitly set to OnTypeMismatch.EMPTY_RESULT, i.e.: @Spec(path="id", onTypeMismatch=EMPTY_RESULT).
OnTypeMismatch| Constructor and Description |
|---|
EmptyResultOnTypeMismatch(org.springframework.data.jpa.domain.Specification<T> wrappedSpec) |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.data.jpa.domain.Specification<T> |
getWrappedSpec() |
javax.persistence.criteria.Predicate |
toPredicate(javax.persistence.criteria.Root<T> root,
javax.persistence.criteria.CriteriaQuery<?> query,
javax.persistence.criteria.CriteriaBuilder cb) |
public EmptyResultOnTypeMismatch(org.springframework.data.jpa.domain.Specification<T> wrappedSpec)
public javax.persistence.criteria.Predicate toPredicate(javax.persistence.criteria.Root<T> root, javax.persistence.criteria.CriteriaQuery<?> query, javax.persistence.criteria.CriteriaBuilder cb)
toPredicate in interface org.springframework.data.jpa.domain.Specification<T>public org.springframework.data.jpa.domain.Specification<T> getWrappedSpec()
Copyright © 2014–2017. All rights reserved.