public abstract class N1qlQuery extends Object implements Serializable
Contract to describe N1QL queries. Queries are formed of a mandatory Statement
and optionally can have other components, as described in each implementation of this.
Also exposes factory methods for different kinds of queries.
Constructor and Description |
---|
N1qlQuery() |
Modifier and Type | Method and Description |
---|---|
abstract JsonObject |
n1ql()
Convert this query to a full N1QL query in Json form.
|
static ParameterizedN1qlQuery |
parameterized(Statement statement,
JsonArray positionalParams)
Create a new query with positionalParameters.
|
static ParameterizedN1qlQuery |
parameterized(Statement statement,
JsonArray positionalParams,
N1qlParams params)
Create a new query with positionalParameters.
|
static ParameterizedN1qlQuery |
parameterized(Statement statement,
JsonObject namedParams)
Create a new query with named parameters.
|
static ParameterizedN1qlQuery |
parameterized(Statement statement,
JsonObject namedParams,
N1qlParams params)
Create a new query with named parameters.
|
static ParameterizedN1qlQuery |
parameterized(String statement,
JsonArray positionalParams)
Create a new query with positionalParameters.
|
static ParameterizedN1qlQuery |
parameterized(String statement,
JsonArray positionalParams,
N1qlParams params)
Create a new query with positionalParameters.
|
static ParameterizedN1qlQuery |
parameterized(String statement,
JsonObject namedParams)
Create a new query with named parameters.
|
static ParameterizedN1qlQuery |
parameterized(String statement,
JsonObject namedParams,
N1qlParams params)
Create a new query with named parameters.
|
abstract N1qlParams |
params()
Returns the
N1qlParams representing customization of the N1QL query. |
static SimpleN1qlQuery |
simple(Statement statement)
|
static SimpleN1qlQuery |
simple(Statement statement,
N1qlParams params)
|
static SimpleN1qlQuery |
simple(String statement)
Create a new
N1qlQuery with a plain raw statement in String form. |
static SimpleN1qlQuery |
simple(String statement,
N1qlParams params)
|
abstract Statement |
statement()
Returns the
Statement from this query. |
public abstract Statement statement()
Returns the Statement
from this query. Note that this is the only mandatory part of a N1QL query.
public abstract N1qlParams params()
Returns the N1qlParams
representing customization of the N1QL query.
Note that this is different from named or positional parameters (which relate to the statement).
N1qlParams
for this query, null if none.public abstract JsonObject n1ql()
Convert this query to a full N1QL query in Json form.
public static SimpleN1qlQuery simple(Statement statement)
statement
- the Statement
to executepublic static SimpleN1qlQuery simple(String statement)
Create a new N1qlQuery
with a plain raw statement in String form.
statement
- the raw statement string to execute (eg. “SELECT * FROM default”).public static SimpleN1qlQuery simple(Statement statement, N1qlParams params)
statement
- the Statement
to executeparams
- the query parameters
.public static SimpleN1qlQuery simple(String statement, N1qlParams params)
statement
- the raw statement string to execute (eg. “SELECT * FROM default”).params
- the query parameters
.public static ParameterizedN1qlQuery parameterized(Statement statement, JsonArray positionalParams)
Create a new query with positionalParameters. Note that the JsonArray
should not be mutated until n1ql()
is called since it backs the creation of the query string.
statement
- the Statement
to execute (containing positional placeholders)positionalParams
- the values for the positional placeholders in statementpublic static ParameterizedN1qlQuery parameterized(Statement statement, JsonObject namedParams)
Create a new query with named parameters. Note that the JsonObject
should not be mutated until n1ql()
is called since it backs the creation of the query string.
statement
- the Statement
to execute (containing named placeholders)namedParams
- the values for the named placeholders in statementpublic static ParameterizedN1qlQuery parameterized(Statement statement, JsonArray positionalParams, N1qlParams params)
Create a new query with positionalParameters. Note that the JsonArray
should not be mutated until n1ql()
is called since it backs the creation of the query string.
statement
- the Statement
to execute (containing positional placeholders)positionalParams
- the values for the positional placeholders in statementparams
- the query parameters
.public static ParameterizedN1qlQuery parameterized(Statement statement, JsonObject namedParams, N1qlParams params)
Create a new query with named parameters. Note that the JsonObject
should not be mutated until n1ql()
is called since it backs the creation of the query string.
statement
- the Statement
to execute (containing named placeholders)namedParams
- the values for the named placeholders in statementparams
- the query parameters
.public static ParameterizedN1qlQuery parameterized(String statement, JsonArray positionalParams)
Create a new query with positionalParameters. Note that the JsonArray
should not be mutated until n1ql()
is called since it backs the creation of the query string.
statement
- the raw statement to execute (containing positional placeholders)positionalParams
- the values for the positional placeholders in statementpublic static ParameterizedN1qlQuery parameterized(String statement, JsonObject namedParams)
Create a new query with named parameters. Note that the JsonObject
should not be mutated until n1ql()
is called since it backs the creation of the query string.
statement
- the raw statement to execute (containing named placeholders)namedParams
- the values for the named placeholders in statementpublic static ParameterizedN1qlQuery parameterized(String statement, JsonArray positionalParams, N1qlParams params)
Create a new query with positionalParameters. Note that the JsonArray
should not be mutated until n1ql()
is called since it backs the creation of the query string.
statement
- the raw statement to execute (containing positional placeholders)positionalParams
- the values for the positional placeholders in statementparams
- the query parameters
.public static ParameterizedN1qlQuery parameterized(String statement, JsonObject namedParams, N1qlParams params)
Create a new query with named parameters. Note that the JsonObject
should not be mutated until n1ql()
is called since it backs the creation of the query string.
statement
- the raw statement to execute (containing named placeholders)namedParams
- the values for the named placeholders in statementparams
- the query parameters
.Copyright © 2014 Couchbase, Inc.