public class N1qlUtils extends Object
Modifier and Type | Field and Description |
---|---|
static Converter<? super CouchbasePersistentProperty,String> |
FIELD_NAME_ESCAPED
A converter that can be used to extract the
fieldName , eg. when
one wants a path from PersistentPropertyPath.toDotPath(Converter) made of escaped field names. |
Constructor and Description |
---|
N1qlUtils() |
Modifier and Type | Method and Description |
---|---|
static N1QLQuery |
buildQuery(N1QLExpression expression,
com.couchbase.client.java.json.JsonValue queryPlaceholderValues,
com.couchbase.client.java.query.QueryScanConsistency scanConsistency)
Creates N1QLQuery object from the statement, query placeholder values and scan consistency
|
static <T> N1QLExpression |
createCountQueryForEntity(String bucketName,
CouchbaseConverter converter,
CouchbaseEntityInformation<T,String> entityInformation)
Creates a full N1QL query that counts total number of the given entity in the bucket.
|
static N1QLExpression |
createReturningExpressionForDelete(String bucketName)
Creates the returning clause for N1ql deletes with all attributes of the entity and meta information
|
static N1QLExpression |
createSelectClauseForEntity(String bucketName)
Produce a
N1QLExpression that corresponds to the SELECT clause for looking for Spring Data entities stored
in Couchbase. |
static N1QLExpression |
createSelectClauseForEntity(String bucketName,
ReturnedType returnedType,
CouchbaseConverter converter)
Produce a
N1QLExpression that corresponds to the SELECT clause for looking for Spring Data entities stored
in Couchbase. |
static N1QLExpression |
createSelectFromForEntity(String bucketName)
Produce a
N1QLExpression that corresponds to the SELECT...FROM clauses for looking for Spring Data entities
stored in Couchbase. |
static N1QLExpression[] |
createSort(Sort sort)
Create a N1QL
N1QLExpression out of a Spring Data Sort . |
static N1QLExpression |
createWhereFilterForEntity(N1QLExpression baseWhereCriteria,
CouchbaseConverter converter,
EntityMetadata<?> entityInformation)
Produces an
N1QLExpression that can serve as a WHERE clause criteria to only select documents in a bucket
that matches a particular Spring Data entity (as given by the EntityMetadata parameter). |
static N1QLExpression |
escapedBucket(String bucketName)
Escape the given bucketName and produce an
N1QLExpression . |
static String |
getDottedPathWithAlternativeFieldNames(PersistentPropertyPath<CouchbasePersistentProperty> path)
Given a
PersistentPropertyPath of CouchbasePersistentProperty (see
getPathWithAlternativeFieldNames(CouchbaseConverter, PropertyPath) ), obtain a String representation of the
path, separated with dots and using alternative field names. |
static PersistentPropertyPath<CouchbasePersistentProperty> |
getPathWithAlternativeFieldNames(CouchbaseConverter converter,
PropertyPath property)
Given a common
PropertyPath , returns the corresponding PersistentPropertyPath of
CouchbasePersistentProperty which will allow to discover alternative naming for fields. |
public static final Converter<? super CouchbasePersistentProperty,String> FIELD_NAME_ESCAPED
fieldName
, eg. when
one wants a path from PersistentPropertyPath.toDotPath(Converter)
made of escaped field names.public static N1QLExpression escapedBucket(String bucketName)
N1QLExpression
.public static N1QLExpression createSelectClauseForEntity(String bucketName, ReturnedType returnedType, CouchbaseConverter converter)
N1QLExpression
that corresponds to the SELECT clause for looking for Spring Data entities stored
in Couchbase. Notably it will select the content of the document AND its id and cas and use custom construction of
query if required.bucketName
- the bucket that stores the entity documents (will be escaped).returnedType
- Returned type projection information from result processor.converter
- couchbase converterpublic static N1QLExpression createReturningExpressionForDelete(String bucketName)
bucketName
- the bucket that stores the entity documents (will be escaped).public static N1QLExpression createSelectClauseForEntity(String bucketName)
N1QLExpression
that corresponds to the SELECT clause for looking for Spring Data entities stored
in Couchbase. Notably it will select the content of the document AND its id and cas.bucketName
- the bucket that stores the entity documents (will be escaped).public static N1QLExpression createSelectFromForEntity(String bucketName)
N1QLExpression
that corresponds to the SELECT...FROM clauses for looking for Spring Data entities
stored in Couchbase. Notably it will select the content of the document AND its id and cas FROM the given bucket.bucketName
- the bucket that stores the entity documents (will be escaped).public static N1QLExpression createWhereFilterForEntity(N1QLExpression baseWhereCriteria, CouchbaseConverter converter, EntityMetadata<?> entityInformation)
N1QLExpression
that can serve as a WHERE clause criteria to only select documents in a bucket
that matches a particular Spring Data entity (as given by the EntityMetadata
parameter).baseWhereCriteria
- the other criteria of the WHERE clause, or null if none.converter
- the CouchbaseConverter
giving the attribute storing the type information can be extracted.entityInformation
- the expected type information.N1QLExpression
to be used as a WHERE clause, that additionally restricts on the given type.public static PersistentPropertyPath<CouchbasePersistentProperty> getPathWithAlternativeFieldNames(CouchbaseConverter converter, PropertyPath property)
PropertyPath
, returns the corresponding PersistentPropertyPath
of
CouchbasePersistentProperty
which will allow to discover alternative naming for fields.public static String getDottedPathWithAlternativeFieldNames(PersistentPropertyPath<CouchbasePersistentProperty> path)
PersistentPropertyPath
of CouchbasePersistentProperty
(see
getPathWithAlternativeFieldNames(CouchbaseConverter, PropertyPath)
), obtain a String representation of the
path, separated with dots and using alternative field names.public static N1QLExpression[] createSort(Sort sort)
N1QLExpression
out of a Spring Data Sort
. Note that the later must use alternative
field names as declared by the Field
annotation on the entity, if any.public static <T> N1QLExpression createCountQueryForEntity(String bucketName, CouchbaseConverter converter, CouchbaseEntityInformation<T,String> entityInformation)
bucketName
- the name of the bucket where data is stored (will be escaped).converter
- the CouchbaseConverter
giving the attribute storing the type information can be extracted.entityInformation
- the counted entity type.public static N1QLQuery buildQuery(N1QLExpression expression, com.couchbase.client.java.json.JsonValue queryPlaceholderValues, com.couchbase.client.java.query.QueryScanConsistency scanConsistency)
expression
- A N1QLExpression
representing the query to executequeryPlaceholderValues
- The positional or named parameters needed for the queryscanConsistency
- The QueryScanConsistency
to be used.N1QLQuery
to be executed.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.