public class StringN1qlBasedQuery extends AbstractN1qlBasedQuery
RepositoryQuery for Couchbase, based on N1QL and a String statement.
The statement can contain positional placeholders (eg. name = $1) that will map to the
method's parameters, in the same order.
The statement can also contain SpEL expressions enclosed in #{ and }.
There are couchbase-provided variables included for the bucket namespace,
the ID and CAS fields necessary for entity reconstruction
or a shortcut that covers SELECT AND FROM clauses,
along with a variable for WHERE clause filtering of the correct entity.| Modifier and Type | Class and Description |
|---|---|
static class |
StringN1qlBasedQuery.N1qlSpelValues
This class is exposed to SpEL parsing through the variable
#. |
| Modifier and Type | Field and Description |
|---|---|
static String |
SPEL_BUCKET
Use this variable in a SpEL expression in a
@Query
annotation's inline statement. |
static String |
SPEL_ENTITY
Use this variable in a SpEL expression in a
@Query
annotation's inline statement. |
static String |
SPEL_FILTER
Use this variable in a SpEL expression in a
@Query
annotation's inline statement WHERE clause. |
static String |
SPEL_PREFIX |
static String |
SPEL_SELECT_FROM_CLAUSE
Use this variable in a SpEL expression in a
@Query
annotation's inline statement. |
queryMethod| Constructor and Description |
|---|
StringN1qlBasedQuery(String statement,
CouchbaseQueryMethod queryMethod,
CouchbaseOperations couchbaseOperations,
SpelExpressionParser spelParser,
EvaluationContextProvider evaluationContextProvider) |
| Modifier and Type | Method and Description |
|---|---|
static StringN1qlBasedQuery.N1qlSpelValues |
createN1qlSpelValues(String bucketName,
String typeField,
Class<?> typeValue,
boolean isCount) |
protected static String |
doParse(String statement,
SpelExpressionParser parser,
EvaluationContext evaluationContext,
StringN1qlBasedQuery.N1qlSpelValues n1qlSpelValues) |
protected com.couchbase.client.java.query.Statement |
getCount(ParameterAccessor accessor,
Object[] runtimeParameters)
The statement for a count() query.
|
protected com.couchbase.client.java.document.json.JsonValue |
getPlaceholderValues(ParameterAccessor accessor) |
com.couchbase.client.java.query.Statement |
getStatement(ParameterAccessor accessor,
Object[] runtimeParameters,
ReturnedType returnedType) |
protected String |
getTypeField() |
protected Class<?> |
getTypeValue() |
protected String |
parseSpel(String statement,
boolean isCount,
Object[] runtimeParameters)
Parse the statement to detect SPEL blocks (delimited by
#{ and })
and replace said expression blocks with their corresponding values. |
protected boolean |
useGeneratedCountQuery() |
buildQuery, execute, executeCollection, executeDependingOnType, executeEntity, executePaged, executeSingleProjection, executeSliced, executeStream, getCouchbaseOperations, getQueryMethodpublic static final String SPEL_PREFIX
public static final String SPEL_SELECT_FROM_CLAUSE
@Query
annotation's inline statement. This will be replaced by the correct SELECT x FROM y clause needed
for entity mapping. Eg. "#{} WHERE test = true".
Note this only makes sense once, as the beginning of the statement.public static final String SPEL_BUCKET
@Query
annotation's inline statement. This will be replaced by the (escaped) bucket name corresponding to the repository's
entity. Eg. "SELECT * FROM #{} LIMIT 3".public static final String SPEL_ENTITY
@Query
annotation's inline statement. This will be replaced by the fields allowing to construct the repository's entity
(SELECT clause). Eg. "SELECT #{} FROM test".public static final String SPEL_FILTER
@Query
annotation's inline statement WHERE clause. This will be replaced by the expression allowing to only select
documents matching the entity's class. Eg. "SELECT * FROM test WHERE test = true AND #{}".public StringN1qlBasedQuery(String statement, CouchbaseQueryMethod queryMethod, CouchbaseOperations couchbaseOperations, SpelExpressionParser spelParser, EvaluationContextProvider evaluationContextProvider)
protected String getTypeField()
protected Class<?> getTypeValue()
public static StringN1qlBasedQuery.N1qlSpelValues createN1qlSpelValues(String bucketName, String typeField, Class<?> typeValue, boolean isCount)
protected String parseSpel(String statement, boolean isCount, Object[] runtimeParameters)
#{ and })
and replace said expression blocks with their corresponding values.statement - the full statement into which SpEL expressions should be parsed and replaced.runtimeParameters - the parameters passed into the method at runtime.protected static String doParse(String statement, SpelExpressionParser parser, EvaluationContext evaluationContext, StringN1qlBasedQuery.N1qlSpelValues n1qlSpelValues)
protected com.couchbase.client.java.document.json.JsonValue getPlaceholderValues(ParameterAccessor accessor)
getPlaceholderValues in class AbstractN1qlBasedQuerypublic com.couchbase.client.java.query.Statement getStatement(ParameterAccessor accessor, Object[] runtimeParameters, ReturnedType returnedType)
getStatement in class AbstractN1qlBasedQueryprotected com.couchbase.client.java.query.Statement getCount(ParameterAccessor accessor, Object[] runtimeParameters)
AbstractN1qlBasedQueryCountFragment.COUNT_ALIAS.getCount in class AbstractN1qlBasedQueryCountFragmentprotected boolean useGeneratedCountQuery()
useGeneratedCountQuery in class AbstractN1qlBasedQuerycount statement should also be used when
the return type of the QueryMethod is a primitive type.Copyright © 2011-2015–2017 Pivotal Software, Inc.. All rights reserved.