Spring Data for VMware GemFire
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:
-
MatcherPatternRegionSortOqlKeywordRepository
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final StringDeprecated.protected static final Patternprotected static final Stringprotected static final Stringprotected static final Patternprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Patternprotected static final Stringprotected static final Stringprotected static final Stringprotected static final StringDeprecated.useSTAR_PROJECTION.protected static final Stringprotected static final Pattern -
Constructor Summary
ConstructorsConstructorDescriptionQueryString(Class<?> domainType) Constructs a new instance ofQueryStringinitialized with the givenapplication domain model typeused to construct an OQL SELECT query statement.QueryString(Class<?> domainType, boolean asCountQuery) Constructs a new instance ofQueryStringinitialized with the givenapplication domain model type, which is used to construct an OQL SELECT query statement.QueryString(String query) Constructs a new instance ofQueryStringinitialized with the givenOQL query. -
Method Summary
Modifier and TypeMethodDescriptionadjustLimit(Integer limit) Replaces an OQL SELECT query with an OQL SELECT DISTINCT query if thequeryis not already distinct; i.e.bindIn(Collection<?> values) Binds the givenCollectionof values into the first IN parameter of the OQL Query (String) by expanding the given values into a comma-separated list.static QueryStringFactory method used to construct a new instance ofQueryStringthat creates anOQL queryto count the number of objects of the specifiedapplication domain model type.static QueryStringFactory method used to construct a new instance ofQueryStringinitialized with the givenapplication domain model typefrom which theOQL querywill be created.fromRegion(Class<?> domainType, org.apache.geode.cache.Region<?, ?> region) Deprecated.fromRegion(org.apache.geode.cache.Region<?, ?> region, Class<?> domainType) protected static StringgetDigitsOnly(String value) Null-safe method used to extract digits from the givenStringvalue as a whole number.Returns the parameter indexes used in this query.intgetLimit()Gets the LIMIT number.protected StringgetQuery()Returns theOQL query statementfrom which thisQueryStringwas constructed.booleanDetermines whether a LIMIT is present in the OQL query.static QueryStringFactory method used to construct a new instance ofQueryStringinitialized with the givenOQL query statement.orderBy(org.springframework.data.domain.Sort sort) Appends theSortorder to this GemFire OQL Query string.toString()Returns aStringrepresentation 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 ofQueryStringinitialized with the givenOQL query.- Parameters:
query-Stringcontaining the OQL query.- Throws:
IllegalArgumentException- ifqueryis null or empty.- See Also:
-
validateQuery(String)String
-
QueryString
Constructs a new instance ofQueryStringinitialized with the givenapplication domain model typeused to construct an OQL SELECT query statement.- Parameters:
domainType-application domain model typeto query; must not be null.- Throws:
IllegalArgumentException- if theapplication domain model typeis null.- See Also:
-
QueryString
Constructs a new instance ofQueryStringinitialized with the givenapplication domain model type, which is used to construct an OQL SELECT query statement.asCountQueryis aBooleanflag indicating whether to select a count or select the contents of the objects for the givenapplicatlion domain model type.- Parameters:
domainType-application domain model typeto query; must not be null.asCountQuery- boolean value to indicate if this is a select count query.- Throws:
IllegalArgumentException- if theapplication domain model typeis null.- See Also:
-
asQuery(Class, boolean)QueryString(String)
-
-
Method Details
-
of
Factory method used to construct a new instance ofQueryStringinitialized with the givenOQL query statement.- Parameters:
query-Stringcontaining the OQL query.- Returns:
- a new
QueryStringinitialized with the givenquery. - Throws:
IllegalArgumentException- ifqueryis null or empty.- See Also:
-
from
Factory method used to construct a new instance ofQueryStringinitialized with the givenapplication domain model typefrom which theOQL querywill be created.- Parameters:
domainType-application domain model typefor which theOQL querywill be created.- Returns:
- a new
QueryStringfor the givenapplication domain model type. - Throws:
IllegalArgumentException- ifapplication domain model typeis null.- See Also:
-
count
Factory method used to construct a new instance ofQueryStringthat creates anOQL queryto count the number of objects of the specifiedapplication domain model type.- Parameters:
domainType-application domain model typefor which the OQL query will be created.- Returns:
- a new count
QueryString. - Throws:
IllegalArgumentException- ifapplication domain model typeis null.- See Also:
-
getDigitsOnly
Null-safe method used to extract digits from the givenStringvalue as a whole number.- Parameters:
value-Stringto evaluate.- Returns:
- the digits extracted from the give
Stringvalue as a whole number or anempty Stringif the givenStringis 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 statementhas a LIMIT.- Returns:
- an
Integervalue containing the LIMIT number orInteger.MAX_VALUEif theOQL query statementis notlimited. - See Also:
-
getQuery
Returns theOQL query statementfrom which thisQueryStringwas constructed.- Returns:
- the
OQL query; never null or empty.
-
adjustLimit
- Parameters:
limit-Integervalue specifying the new query LIMIT.- Returns:
- a new
QueryStringwith the adjusted query LIMIT. - See Also:
-
asDistinct
Replaces an OQL SELECT query with an OQL SELECT DISTINCT query if thequeryis not already distinct; i.e. does not contain the DISTINCT OQL keyword. -
bindIn
Binds the givenCollectionof values into the first IN parameter of the OQL Query (String) by expanding the given values into a comma-separated list.- Parameters:
values-Collectionof values to bind; must not be null or empty.- Returns:
- a new
QueryStringhaving IN parameter bound with values or returns thisQueryStringif theCollectionof values is null or empty. - See Also:
-
fromRegion
- Parameters:
region-Regionto query; must not be null.domainType-typeof the persistent entity to query; must not be null.- Returns:
- a new
QueryStringwith an OQL SELECT statement having a FROM clause based on the selectedRegion. - See Also:
-
RegionClass
-
fromRegion
@Deprecated public QueryString fromRegion(Class<?> domainType, org.apache.geode.cache.Region<?, ?> region) Deprecated. -
orderBy
Appends theSortorder to this GemFire OQL Query string.- Parameters:
sort-Sortindicating the order of the query results.- Returns:
- a new
QueryStringwith an ORDER BY clause ifSortis not null, or thisQueryStringas-is ifSortis null. - See Also:
-
SortQueryString
-
withHints
Applies HINTS to the OQL Query.- Parameters:
hints- array ofStringscontaining query hints.- Returns:
- a new
QueryStringif hints are not null or empty, or return thisQueryString.
-
withImport
Applies an IMPORT to the OQL Query.- Parameters:
importExpression-Stringcontaining the import clause.- Returns:
- a new
QueryStringif an import was declared, or return thisQueryString.
-
withLimit
Applies a LIMIT to the OQL Query.- Parameters:
limit-Integerindicating the number of results to return from the query.- Returns:
- a new
QueryStringif a limit was specified, or return thisQueryString.
-
withTrace
Applies TRACE logging to the OQL Query.- Returns:
- a new
QueryStringwith tracing enabled.
-
toString
- Overrides:
toStringin classObject- Returns:
- a
Stringrepresentation of thisQueryString. - See Also:
-
COUNT_PROJECTION.