Package com.couchbase.client.java.query
Class PreparedN1qlQuery
- java.lang.Object
-
- com.couchbase.client.java.query.N1qlQuery
-
- com.couchbase.client.java.query.AbstractN1qlQuery
-
- com.couchbase.client.java.query.ParameterizedN1qlQuery
-
- com.couchbase.client.java.query.PreparedN1qlQuery
-
- All Implemented Interfaces:
Serializable
@Uncommitted @Private public class PreparedN1qlQuery extends ParameterizedN1qlQuery
Represent a N1QL query, with a parameterized prepared statement plan (for which the values must be passed according to the type and number of placeholders). Positional placeholders (in the form of either "$1" "$2" or just simple "?") are filled by the values taken from aJsonArray
. Named placeholders (in the form of "$param1", "$myOtherParam", etc...) are filled by the values taken from aJsonObject
. If in this JsonObject attributes don't have the $ prefix, it is added upon building the query.- Since:
- 2.1
- Author:
- Simon Baslé
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PreparedN1qlQuery(PreparedPayload plan, JsonArray positionalParams, N1qlParams params)
PreparedN1qlQuery(PreparedPayload plan, JsonObject namedParams, N1qlParams params)
PreparedN1qlQuery(PreparedPayload plan, N1qlParams params)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isEncodedPlanEnabled()
Returns whether or not the encodedPlan part of the payload will be made part of the N1QL statement.JsonObject
n1ql()
Convert this query to a full N1QL query in Json form.void
setEncodedPlanEnabled(boolean enabled)
Toggle whether or not the encodedPlan part of the payload should be made part of the N1QL statement.PreparedPayload
statement()
Returns theStatement
from this query.protected String
statementType()
The type of the statement, used as JSON name in the final JSON form of the queryprotected Object
statementValue()
The JSON representation for the underlyingStatement
in the final JSON form of the query-
Methods inherited from class com.couchbase.client.java.query.ParameterizedN1qlQuery
isPositional, statementParameters, toString
-
Methods inherited from class com.couchbase.client.java.query.AbstractN1qlQuery
params, populateParameters
-
Methods inherited from class com.couchbase.client.java.query.N1qlQuery
parameterized, parameterized, parameterized, parameterized, parameterized, parameterized, parameterized, parameterized, simple, simple, simple, simple
-
-
-
-
Constructor Detail
-
PreparedN1qlQuery
public PreparedN1qlQuery(PreparedPayload plan, JsonArray positionalParams, N1qlParams params)
-
PreparedN1qlQuery
public PreparedN1qlQuery(PreparedPayload plan, JsonObject namedParams, N1qlParams params)
-
PreparedN1qlQuery
public PreparedN1qlQuery(PreparedPayload plan, N1qlParams params)
-
-
Method Detail
-
statementType
protected String statementType()
Description copied from class:AbstractN1qlQuery
The type of the statement, used as JSON name in the final JSON form of the query- Overrides:
statementType
in classParameterizedN1qlQuery
-
statementValue
protected Object statementValue()
Description copied from class:AbstractN1qlQuery
The JSON representation for the underlyingStatement
in the final JSON form of the query- Overrides:
statementValue
in classParameterizedN1qlQuery
-
statement
public PreparedPayload statement()
Description copied from class:N1qlQuery
Returns theStatement
from this query. Note that this is the only mandatory part of a N1QL query.- Overrides:
statement
in classAbstractN1qlQuery
- Returns:
- the statement that forms the base of this query
-
setEncodedPlanEnabled
public void setEncodedPlanEnabled(boolean enabled)
Toggle whether or not the encodedPlan part of the payload should be made part of the N1QL statement.- Parameters:
enabled
- true to activate encodedPlan in the N1QL statement, false to avoid including it.
-
isEncodedPlanEnabled
public boolean isEncodedPlanEnabled()
Returns whether or not the encodedPlan part of the payload will be made part of the N1QL statement.- Returns:
- true if encodedPlan is to be used in statement, false otherwise.
-
n1ql
public JsonObject n1ql()
Description copied from class:N1qlQuery
Convert this query to a full N1QL query in Json form.- Overrides:
n1ql
in classAbstractN1qlQuery
- Returns:
- the json representation of this query (including all relevant parameters)
-
-