Class StringBasedN1qlQueryParser
java.lang.Object
org.springframework.data.couchbase.repository.query.StringBasedN1qlQueryParser
- Author:
- Subhashni Balakrishnan, Michael Reiche, Tigran Babloyan
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
This class is exposed to SpEL parsing through the variable#"n1ql"
. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Pattern
regexp that detect $named placeholder (starts with a letter, then alphanum chars)final N1QLExpression
static final Pattern
regexp that detect positional placeholder ($ followed by digits only)static final Pattern
regexp that detects " and ' quote boundaries, ignoring escaped quotesstatic final String
Use this variable in a SpEL expression in a@Query
annotation's inline statement.static final String
Use this variable in a SpEL expression in a@Query
annotation's inline statement.static final String
Use this variable in a SpEL expression in a@Query
annotation's inline statement.static final String
Use this variable in a SpEL expression in a@Query
annotation's inline statement.static final Pattern
regexp that detect SPEL Expression (#{..})static final String
Use this variable in a SpEL expression in a@Query
annotation's inline statement WHERE clause.static final String
static final String
Use this variable in a SpEL expression in a@Query
annotation's inline statement.static final String
Use this variable in a SpEL expression in a@Query
annotation's inline statement.static final String
Use this variable in a SpEL expression in a@Query
annotation's inline statement. -
Constructor Summary
ConstructorDescriptionStringBasedN1qlQueryParser
(String bucketName, String scope, String collection, CouchbaseConverter couchbaseConverter, Class<?> domainClass, Class<?> resultClass, String typeField, String typeValue, boolean isCount, String[] distinctFields, String[] fields) This constructor is to allow for generating the n1ql spel expressions from NON-@Queries.StringBasedN1qlQueryParser
(String statement, CouchbaseQueryMethod queryMethod, String bucketName, String scope, String collection, CouchbaseConverter couchbaseConverter, String typeField, String typeValue, ParameterAccessor accessor, SpelExpressionParser spelExpressionParser, QueryMethodEvaluationContextProvider evaluationContextProvider) This constructor is to allow for generating the n1ql spel expressions from @Queries. -
Method Summary
Modifier and TypeMethodDescriptioncreateN1qlSpelValues
(String bucketName, String scope, String collection, Class domainClass, String typeKey, String typeValue, boolean isCount, String[] distinctFields, String[] fields) Create the n1ql spel values.static String
doParse
(String statement, SpelExpressionParser parser, EvaluationContext evaluationContext, StringBasedN1qlQueryParser.N1qlSpelValues n1qlSpelValues) getExpression
(String statement, CouchbaseQueryMethod queryMethod, ParameterAccessor accessor, SpelExpressionParser parser, QueryMethodEvaluationContextProvider evaluationContextProvider) Creates the N1QLExpression and parameterNamescom.couchbase.client.java.json.JsonValue
getPlaceholderValues
(ParameterAccessor accessor) protected boolean
-
Field Details
-
SPEL_PREFIX
- See Also:
-
SPEL_SELECT_FROM_CLAUSE
Use this variable in a SpEL expression in a@Query
annotation's inline statement. This will be replaced by the correctSELECT x FROM y
clause needed for entity mapping. Eg."#{"#n1ql.selectEntity"} WHERE test = true"
. Note this only makes sense once, as the beginning of the statement.- See Also:
-
SPEL_BUCKET
Use this variable in a SpEL expression in a@Query
annotation's inline statement. This will be replaced by the (escaped) bucket name corresponding to the repository's entity. Eg."SELECT * FROM #{"#n1ql.bucket"} LIMIT 3"
.- See Also:
-
SPEL_SCOPE
Use this variable in a SpEL expression in a@Query
annotation's inline statement. This will be replaced by the (escaped) scope name. Eg."SELECT * FROM #{"#n1ql.scope"}.#{"#n1ql.collection"} LIMIT 3"
.- See Also:
-
SPEL_COLLECTION
Use this variable in a SpEL expression in a@Query
annotation's inline statement. This will be replaced by the (escaped) collection name. Eg."SELECT * FROM #{"#n1ql.scope"}.#{"#n1ql.collection"} LIMIT 3"
.- See Also:
-
SPEL_ENTITY
Use this variable in a SpEL expression in a@Query
annotation's inline statement. This will be replaced by the fields allowing to construct the repository's entity (SELECT clause). Eg."SELECT #{"#n1ql.fields"} FROM test"
.- See Also:
-
SPEL_FILTER
Use this variable in a SpEL expression in a@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 #{"#n1ql.filter"}"
.- See Also:
-
SPEL_DELETE
Use this variable in a SpEL expression in a@Query
annotation's inline statement. This will be replaced by the correctdelete
expression needed Eg."#{"#n1ql.delete"} WHERE test = true"
. Note this only makes sense once, as the beginning of the statement.- See Also:
-
SPEL_RETURNING
Use this variable in a SpEL expression in a@Query
annotation's inline statement. This will be replaced by the correctreturning
clause needed for entity mapping. Eg."#{"#n1ql.returning"} WHERE test = true"
. Note this only makes sense once, as the beginning of the statement.- See Also:
-
NAMED_PLACEHOLDER_PATTERN
regexp that detect $named placeholder (starts with a letter, then alphanum chars) -
POSITIONAL_PLACEHOLDER_PATTERN
regexp that detect positional placeholder ($ followed by digits only) -
SPEL_EXPRESSION_PATTERN
regexp that detect SPEL Expression (#{..}) -
QUOTE_DETECTION_PATTERN
regexp that detects " and ' quote boundaries, ignoring escaped quotes -
parsedExpression
-
-
Constructor Details
-
StringBasedN1qlQueryParser
public StringBasedN1qlQueryParser(String statement, CouchbaseQueryMethod queryMethod, String bucketName, String scope, String collection, CouchbaseConverter couchbaseConverter, String typeField, String typeValue, ParameterAccessor accessor, SpelExpressionParser spelExpressionParser, QueryMethodEvaluationContextProvider evaluationContextProvider) This constructor is to allow for generating the n1ql spel expressions from @Queries.- Parameters:
statement
-queryMethod
-bucketName
-scope
-collection
-couchbaseConverter
-typeField
-typeValue
-accessor
-spelExpressionParser
-evaluationContextProvider
-
-
StringBasedN1qlQueryParser
public StringBasedN1qlQueryParser(String bucketName, String scope, String collection, CouchbaseConverter couchbaseConverter, Class<?> domainClass, Class<?> resultClass, String typeField, String typeValue, boolean isCount, String[] distinctFields, String[] fields) This constructor is to allow for generating the n1ql spel expressions from NON-@Queries. For selects, n1ql.selectEntity and n1ql.filter. FOr deletes, n1ql.delete, n1ql.filter and n1ql.returning- Parameters:
bucketName
-scope
-collection
-couchbaseConverter
-domainClass
-resultClass
-typeField
-typeValue
-isCount
-distinctFields
-fields
-
-
-
Method Details
-
createN1qlSpelValues
public StringBasedN1qlQueryParser.N1qlSpelValues createN1qlSpelValues(String bucketName, String scope, String collection, Class domainClass, String typeKey, String typeValue, boolean isCount, String[] distinctFields, String[] fields) Create the n1ql spel values. The domainClass is needed, but not the returnClass. Mapping the domainClass to the returnClass is the responsibility of decoding.- Parameters:
bucketName
-scope
-collection
-domainClass
-typeKey
-typeValue
-isCount
-distinctFields
-fields
-- Returns:
-
doParse
public static String doParse(String statement, SpelExpressionParser parser, EvaluationContext evaluationContext, StringBasedN1qlQueryParser.N1qlSpelValues n1qlSpelValues) -
getPlaceholderValues
-
useGeneratedCountQuery
protected boolean useGeneratedCountQuery() -
getStatementContext
-
getStatement
-
getExpression
public N1QLExpression getExpression(String statement, CouchbaseQueryMethod queryMethod, ParameterAccessor accessor, SpelExpressionParser parser, QueryMethodEvaluationContextProvider evaluationContextProvider) Creates the N1QLExpression and parameterNames- Parameters:
statement
-queryMethod
-accessor
-parser
-evaluationContextProvider
-- Returns:
-