Query DSL with Parameters

Wolfgang Schuetzelhofer edited this page Jul 31, 2017 · 7 revisions
Previous Next Table of Contents

Query DSL with Parameters

You can use parameters (JcQueryParameter) with Query DSL expressions. This allows to reuse Query DSL Expressions with different values for the specified parameters.

Note: Don't confuse this with 'Parameterized CYPHER Expressions'. 'Parameterized CYPHER Expressions' are generated in the background whenever the use of parameters with CYPHER is possible. This allows Neo4J to optimize queries.

Here is a code snippet about how to use parameters with Query DSL Expressions.

// specify a query parameter
JcQueryParameter memberName = new JcQueryParameter("memberName");
// set the parameter value

// specify the query
JcNode n = new JcNode("n");
IClause[] clauses = new IClause[] {
   // match nodes
JcQuery query = new JcQuery();

// execute the query
JcQueryResult result = dbAccess.execute(query);

// modify the parameter value

// execute the query again
result = dbAccess.execute(query);

Previous Next Table of Contents