Class EmptyResultOnTypeMismatch<T>
java.lang.Object
net.kaczmarzyk.spring.data.jpa.domain.EmptyResultOnTypeMismatch<T>
- All Implemented Interfaces:
Serializable,org.springframework.data.jpa.domain.Specification<T>
- Direct Known Subclasses:
IgnoreOnTypeMismatch
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).
- Author:
- Tomasz Kaczmarzyk
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEmptyResultOnTypeMismatch(org.springframework.data.jpa.domain.Specification<T> wrappedSpec) -
Method Summary
Modifier and TypeMethodDescriptionbooleanorg.springframework.data.jpa.domain.Specification<T>inthashCode()jakarta.persistence.criteria.PredicatetoPredicate(jakarta.persistence.criteria.Root<T> root, jakarta.persistence.criteria.CriteriaQuery<?> query, jakarta.persistence.criteria.CriteriaBuilder cb) toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.data.jpa.domain.Specification
and, or
-
Constructor Details
-
EmptyResultOnTypeMismatch
-
-
Method Details
-
toPredicate
public jakarta.persistence.criteria.Predicate toPredicate(jakarta.persistence.criteria.Root<T> root, jakarta.persistence.criteria.CriteriaQuery<?> query, jakarta.persistence.criteria.CriteriaBuilder cb) - Specified by:
toPredicatein interfaceorg.springframework.data.jpa.domain.Specification<T>
-
getWrappedSpec
-
toString
-
hashCode
public int hashCode() -
equals
-