Class QueryString
java.lang.Object
org.springframework.data.gemfire.repository.query.QueryString
- Direct Known Subclasses:
PagedQueryString
QueryString
is a base class used to construct and model syntactically valid Apache Geode
OQL query statements.
QueryString
uses Pattern
based recognition and matching
to parse and modify
the OQL query statement.
This is an internal class used by the SDG Repository
infrastructure extension.- See Also:
-
Matcher
Pattern
Region
Sort
OqlKeyword
Repository
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
Deprecated.protected static final Pattern
protected static final String
protected static final String
protected static final Pattern
protected static final String
protected static final String
protected static final String
protected static final String
protected static final Pattern
protected static final String
protected static final String
protected static final String
protected static final String
Deprecated.useSTAR_PROJECTION
.protected static final String
protected static final Pattern
-
Constructor Summary
ConstructorDescriptionQueryString
(Class<?> domainType) Constructs a new instance ofQueryString
initialized with the givenapplication domain model type
used to construct an OQL SELECT query statement.QueryString
(Class<?> domainType, boolean asCountQuery) Constructs a new instance ofQueryString
initialized with the givenapplication domain model type
, which is used to construct an OQL SELECT query statement.QueryString
(String query) Constructs a new instance ofQueryString
initialized with the givenOQL query
. -
Method Summary
Modifier and TypeMethodDescriptionadjustLimit
(Integer limit) Replaces an OQL SELECT query with an OQL SELECT DISTINCT query if thequery
is not already distinct; i.e.bindIn
(Collection<?> values) Binds the givenCollection
of values into the first IN parameter of the OQL Query (String
) by expanding the given values into a comma-separated list.static QueryString
Factory method used to construct a new instance ofQueryString
that creates anOQL query
to count the number of objects of the specifiedapplication domain model type
.static QueryString
Factory method used to construct a new instance ofQueryString
initialized with the givenapplication domain model type
from which theOQL query
will be created.fromRegion
(Class<?> domainType, org.apache.geode.cache.Region<?, ?> region) Deprecated.fromRegion
(org.apache.geode.cache.Region<?, ?> region, Class<?> domainType) protected static String
getDigitsOnly
(String value) Null-safe method used to extract digits from the givenString
value as a whole number.Returns the parameter indexes used in this query.int
getLimit()
Gets the LIMIT number.protected String
getQuery()
Returns theOQL query statement
from which thisQueryString
was constructed.boolean
Determines whether a LIMIT is present in the OQL query.static QueryString
Factory method used to construct a new instance ofQueryString
initialized with the givenOQL query statement
.orderBy
(org.springframework.data.domain.Sort sort) Appends theSort
order to this GemFire OQL Query string.toString()
Returns aString
representation of thisQueryString
.Applies HINTS to the OQL Query.withImport
(String importExpression) Applies an IMPORT to the OQL Query.Applies a LIMIT to the OQL Query.Applies TRACE logging to the OQL Query.
-
Field Details
-
HINT_PATTERN
-
IMPORT_PATTERN
-
LIMIT_PATTERN
-
TRACE_PATTERN
-
HINTS_OQL_TEMPLATE
- See Also:
-
IMPORT_OQL_TEMPLATE
- See Also:
-
LIMIT_OQL_TEMPLATE
- See Also:
-
SELECT_OQL_TEMPLATE
- See Also:
-
TRACE_OQL_TEMPLATE
- See Also:
-
COUNT_PROJECTION
- See Also:
-
IN_PATTERN
- See Also:
-
IN_PARAMETER_PATTERN
- See Also:
-
IN_VALUES_TEMPLATE
- See Also:
-
REGION_PATTERN
- See Also:
-
STAR_PROJECTION
- See Also:
-
COUNT_QUERY
Deprecated.useCOUNT_PROJECTION
.- See Also:
-
STAR_QUERY
Deprecated.useSTAR_PROJECTION
.- See Also:
-
-
Constructor Details
-
QueryString
Constructs a new instance ofQueryString
initialized with the givenOQL query
.- Parameters:
query
-String
containing the OQL query.- Throws:
IllegalArgumentException
- ifquery
is null or empty.- See Also:
-
validateQuery(String)
String
-
QueryString
Constructs a new instance ofQueryString
initialized with the givenapplication domain model type
used to construct an OQL SELECT query statement.- Parameters:
domainType
-application domain model type
to query; must not be null.- Throws:
IllegalArgumentException
- if theapplication domain model type
is null.- See Also:
-
QueryString
Constructs a new instance ofQueryString
initialized with the givenapplication domain model type
, which is used to construct an OQL SELECT query statement.asCountQuery
is aBoolean
flag indicating whether to select a count or select the contents of the objects for the givenapplicatlion domain model type
.- Parameters:
domainType
-application domain model type
to query; must not be null.asCountQuery
- boolean value to indicate if this is a select count query.- Throws:
IllegalArgumentException
- if theapplication domain model type
is null.- See Also:
-
asQuery(Class, boolean)
QueryString(String)
-
-
Method Details
-
of
Factory method used to construct a new instance ofQueryString
initialized with the givenOQL query statement
.- Parameters:
query
-String
containing the OQL query.- Returns:
- a new
QueryString
initialized with the givenquery
. - Throws:
IllegalArgumentException
- ifquery
is null or empty.- See Also:
-
from
Factory method used to construct a new instance ofQueryString
initialized with the givenapplication domain model type
from which theOQL query
will be created.- Parameters:
domainType
-application domain model type
for which theOQL query
will be created.- Returns:
- a new
QueryString
for the givenapplication domain model type
. - Throws:
IllegalArgumentException
- ifapplication domain model type
is null.- See Also:
-
count
Factory method used to construct a new instance ofQueryString
that creates anOQL query
to count the number of objects of the specifiedapplication domain model type
.- Parameters:
domainType
-application domain model type
for which the OQL query will be created.- Returns:
- a new count
QueryString
. - Throws:
IllegalArgumentException
- ifapplication domain model type
is null.- See Also:
-
getDigitsOnly
Null-safe method used to extract digits from the givenString
value as a whole number.- Parameters:
value
-String
to evaluate.- Returns:
- the digits extracted from the give
String
value as a whole number or anempty String
if the givenString
is null, empty or contains no digits. - See Also:
-
isLimited
public boolean isLimited()Determines whether a LIMIT is present in the OQL query.- Returns:
- a boolean value determining whether a LIMIT is present in the OQL query.
- See Also:
-
getInParameterIndexes
Returns the parameter indexes used in this query. -
getLimit
public int getLimit()Gets the LIMIT number. UseisLimited()
to determine whether theOQL query statement
has a LIMIT.- Returns:
- an
Integer
value containing the LIMIT number orInteger.MAX_VALUE
if theOQL query statement
is notlimited
. - See Also:
-
getQuery
Returns theOQL query statement
from which thisQueryString
was constructed.- Returns:
- the
OQL query
; never null or empty.
-
adjustLimit
- Parameters:
limit
-Integer
value specifying the new query LIMIT.- Returns:
- a new
QueryString
with the adjusted query LIMIT. - See Also:
-
asDistinct
Replaces an OQL SELECT query with an OQL SELECT DISTINCT query if thequery
is not already distinct; i.e. does not contain the DISTINCT OQL keyword. -
bindIn
Binds the givenCollection
of values into the first IN parameter of the OQL Query (String
) by expanding the given values into a comma-separated list.- Parameters:
values
-Collection
of values to bind; must not be null or empty.- Returns:
- a new
QueryString
having IN parameter bound with values or returns thisQueryString
if theCollection
of values is null or empty. - See Also:
-
fromRegion
- Parameters:
region
-Region
to query; must not be null.domainType
-type
of the persistent entity to query; must not be null.- Returns:
- a new
QueryString
with an OQL SELECT statement having a FROM clause based on the selectedRegion
. - See Also:
-
Region
Class
-
fromRegion
@Deprecated public QueryString fromRegion(Class<?> domainType, org.apache.geode.cache.Region<?, ?> region) Deprecated. -
orderBy
Appends theSort
order to this GemFire OQL Query string.- Parameters:
sort
-Sort
indicating the order of the query results.- Returns:
- a new
QueryString
with an ORDER BY clause ifSort
is not null, or thisQueryString
as-is ifSort
is null. - See Also:
-
Sort
QueryString
-
withHints
Applies HINTS to the OQL Query.- Parameters:
hints
- array ofStrings
containing query hints.- Returns:
- a new
QueryString
if hints are not null or empty, or return thisQueryString
.
-
withImport
Applies an IMPORT to the OQL Query.- Parameters:
importExpression
-String
containing the import clause.- Returns:
- a new
QueryString
if an import was declared, or return thisQueryString
.
-
withLimit
Applies a LIMIT to the OQL Query.- Parameters:
limit
-Integer
indicating the number of results to return from the query.- Returns:
- a new
QueryString
if a limit was specified, or return thisQueryString
.
-
withTrace
Applies TRACE logging to the OQL Query.- Returns:
- a new
QueryString
with tracing enabled.
-
toString
- Overrides:
toString
in classObject
- Returns:
- a
String
representation of thisQueryString
. - See Also:
-
COUNT_PROJECTION
.