Class Criteria
java.lang.Object
org.springframework.data.relational.core.query.Criteria
- All Implemented Interfaces:
CriteriaDefinition
Central class for creating queries. It follows a fluent API style so that you can easily chain together multiple
criteria. Static import of the
Criteria.property(…)
method will improve readability as in
where(property(…).is(…)
.
The Criteria API supports composition with a NULL object
and a static factory
method
. Example usage:
Criteria.from(Criteria.where("name").is("Foo"), Criteria.from(Criteria.where("age").greaterThan(42)));rendering:
WHERE name = 'Foo' AND age > 42
- Since:
- 2.0
- Author:
- Mark Paluch, Oliver Drotbohm, Roman Chigvintsev, Jens Schauder
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Interface declaring terminal builder methods to build aCriteria
.Nested classes/interfaces inherited from interface org.springframework.data.relational.core.query.CriteriaDefinition
CriteriaDefinition.Combinator, CriteriaDefinition.Comparator
-
Method Summary
Modifier and TypeMethodDescriptionand
(List<? extends CriteriaDefinition> criteria) and
(CriteriaDefinition criteria) static Criteria
empty()
Static factory method to create an empty Criteria.static Criteria
static Criteria
getGroup()
getValue()
boolean
ignoreCase
(boolean ignoreCase) Creates a newCriteria
with the given "ignore case" flag.boolean
isEmpty()
boolean
isGroup()
boolean
Checks whether comparison should be done in case-insensitive way.or
(List<? extends CriteriaDefinition> criteria) or
(CriteriaDefinition criteria) toString()
static Criteria.CriteriaStep
Static factory method to create a Criteria using the providedcolumn
name.
-
Method Details
-
empty
Static factory method to create an empty Criteria.- Returns:
- an empty
Criteria
.
-
from
- Returns:
- new
Criteria
.
-
from
- Returns:
- new
Criteria
.
-
where
Static factory method to create a Criteria using the providedcolumn
name.- Parameters:
column
- Must not be null or empty.- Returns:
- a new
Criteria.CriteriaStep
object to complete the firstCriteria
.
-
and
- Parameters:
column
- Must not be null or empty.- Returns:
- a new
Criteria.CriteriaStep
object to complete the nextCriteria
.
-
and
- Parameters:
criteria
- criteria object.- Returns:
- a new
Criteria
object. - Since:
- 1.1
-
and
- Parameters:
criteria
- criteria objects.- Returns:
- a new
Criteria
object.
-
or
- Parameters:
column
- Must not be null or empty.- Returns:
- a new
Criteria.CriteriaStep
object to complete the nextCriteria
.
-
or
- Parameters:
criteria
- criteria object.- Returns:
- a new
Criteria
object. - Since:
- 1.1
-
or
- Parameters:
criteria
- criteria object.- Returns:
- a new
Criteria
object. - Since:
- 1.1
-
ignoreCase
Creates a newCriteria
with the given "ignore case" flag.- Parameters:
ignoreCase
- true if comparison should be done in case-insensitive way- Returns:
- a new
Criteria
object
-
getPrevious
- Specified by:
getPrevious
in interfaceCriteriaDefinition
- Returns:
- the previous
Criteria
object. Can be null if there is no previousCriteria
. - See Also:
-
hasPrevious
public boolean hasPrevious()- Specified by:
hasPrevious
in interfaceCriteriaDefinition
- Returns:
- true if this
Criteria
has a previous one.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCriteriaDefinition
- Returns:
- true if this
Criteria
is empty. - Since:
- 1.1
-
isGroup
public boolean isGroup()- Specified by:
isGroup
in interfaceCriteriaDefinition
- Returns:
- true if this
Criteria
is empty.
-
getCombinator
- Specified by:
getCombinator
in interfaceCriteriaDefinition
- Returns:
CriteriaDefinition.Combinator
to combine this criteria with a previous one.
-
getGroup
- Specified by:
getGroup
in interfaceCriteriaDefinition
-
getColumn
- Specified by:
getColumn
in interfaceCriteriaDefinition
- Returns:
- the column/property name.
-
getComparator
- Specified by:
getComparator
in interfaceCriteriaDefinition
- Returns:
CriteriaDefinition.Comparator
.
-
getValue
- Specified by:
getValue
in interfaceCriteriaDefinition
- Returns:
- the comparison value. Can be null.
-
isIgnoreCase
public boolean isIgnoreCase()Checks whether comparison should be done in case-insensitive way.- Specified by:
isIgnoreCase
in interfaceCriteriaDefinition
- Returns:
- true if comparison should be done in case-insensitive way
-
toString
-