Class StringBasedN1qlQueryParser

java.lang.Object
org.springframework.data.couchbase.repository.query.StringBasedN1qlQueryParser

public class StringBasedN1qlQueryParser extends Object
Author:
Subhashni Balakrishnan, Michael Reiche, Tigran Babloyan
  • Field Details

    • SPEL_PREFIX

      public static final String SPEL_PREFIX
      See Also:
    • SPEL_SELECT_FROM_CLAUSE

      public static final String SPEL_SELECT_FROM_CLAUSE
      Use this variable in a SpEL expression in a @Query annotation's inline statement. This will be replaced by the correct SELECT 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

      public static final String 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

      public static final String 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

      public static final String 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

      public static final String 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

      public static final String 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

      public static final String SPEL_DELETE
      Use this variable in a SpEL expression in a @Query annotation's inline statement. This will be replaced by the correct delete expression needed Eg. "#{"#n1ql.delete"} WHERE test = true". Note this only makes sense once, as the beginning of the statement.
      See Also:
    • SPEL_RETURNING

      public static final String SPEL_RETURNING
      Use this variable in a SpEL expression in a @Query annotation's inline statement. This will be replaced by the correct returning 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

      public static final Pattern NAMED_PLACEHOLDER_PATTERN
      regexp that detect $named placeholder (starts with a letter, then alphanum chars)
    • POSITIONAL_PLACEHOLDER_PATTERN

      public static final Pattern POSITIONAL_PLACEHOLDER_PATTERN
      regexp that detect positional placeholder ($ followed by digits only)
    • SPEL_EXPRESSION_PATTERN

      public static final Pattern SPEL_EXPRESSION_PATTERN
      regexp that detect SPEL Expression (#{..})
    • QUOTE_DETECTION_PATTERN

      public static final Pattern QUOTE_DETECTION_PATTERN
      regexp that detects " and ' quote boundaries, ignoring escaped quotes
    • parsedExpression

      public final N1QLExpression 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