use of com.couchbase.client.java.query.ParameterizedN1qlQuery in project neo4j-apoc-procedures by neo4j-contrib.
the class CouchbaseConnection method executeParametrizedStatement.
/**
* Executes a N1QL statement with named parameters.
*
* @param statement
* the raw statement string to execute (containing named
* placeholders: $param1, $param2, ...)
* @param parameterNames
* the placeholders' names in statement
* @param parameterValues
* the values for the named placeholders in statement
* @return the list of {@link JsonObject}s retrieved by this query
*
* @see N1qlQuery#parameterized(Statement, JsonObject)
*/
public List<JsonObject> executeParametrizedStatement(String statement, List<String> parameterNames, List<Object> parameterValues) {
JsonObject namedParams = JsonObject.create();
for (int param = 0; param < parameterNames.size(); param++) {
namedParams.put(parameterNames.get(param), parameterValues.get(param));
}
ParameterizedN1qlQuery query = N1qlQuery.parameterized(statement, namedParams);
return executeQuery(query);
}
use of com.couchbase.client.java.query.ParameterizedN1qlQuery in project jnosql-diana-driver by eclipse.
the class DefaultCouchbaseDocumentCollectionManager method delete.
@Override
public void delete(DocumentDeleteQuery query) {
QueryConverter.QueryConverterResult delete = QueryConverter.delete(query, database);
if (nonNull(delete.getStatement())) {
ParameterizedN1qlQuery n1qlQuery = N1qlQuery.parameterized(delete.getStatement(), delete.getParams());
bucket.query(n1qlQuery);
}
if (!delete.getKeys().isEmpty()) {
delete.getKeys().stream().map(s -> getPrefix(query.getDocumentCollection(), s)).forEach(bucket::remove);
}
}
use of com.couchbase.client.java.query.ParameterizedN1qlQuery in project neo4j-apoc-procedures by neo4j-contrib.
the class CouchbaseConnection method executeParametrizedStatement.
/**
* Executes a N1QL statement with positional parameters.
*
* @param statement
* the raw statement string to execute (containing positional
* placeholders: $1, $2, ...)
* @param parameters
* the values for the positional placeholders in statement
* @return the list of {@link JsonObject}s retrieved by this query
*
* @see N1qlQuery#parameterized(Statement, JsonArray)
*/
public List<JsonObject> executeParametrizedStatement(String statement, List<Object> parameters) {
JsonArray positionalParams = JsonArray.from(parameters);
ParameterizedN1qlQuery query = N1qlQuery.parameterized(statement, positionalParams);
return executeQuery(query);
}
use of com.couchbase.client.java.query.ParameterizedN1qlQuery in project jnosql-diana-driver by eclipse.
the class DefaultCouchbaseDocumentCollectionManager method select.
@Override
public List<DocumentEntity> select(DocumentQuery query) throws NullPointerException {
QueryConverter.QueryConverterResult select = QueryConverter.select(query, database);
List<DocumentEntity> entities = new ArrayList<>();
if (nonNull(select.getStatement())) {
ParameterizedN1qlQuery n1qlQuery = N1qlQuery.parameterized(select.getStatement(), select.getParams());
N1qlQueryResult result = bucket.query(n1qlQuery);
entities.addAll(convert(result, database));
}
if (!select.getKeys().isEmpty()) {
entities.addAll(convert(select.getKeys(), bucket));
}
return entities;
}
Aggregations