Skip to content
Browse files
Query building substitution()
  • Loading branch information
afs committed Dec 9, 2021
1 parent e52d3c0 commit 8590d1ea2594a2a7b357e603642da871beeed5a4
Showing 3 changed files with 42 additions and 9 deletions.
@@ -3,6 +3,7 @@


# IntelliJ generated
@@ -11,4 +12,4 @@ target/

# Hugo
@@ -446,7 +446,6 @@ custom query engine and overriding `QueryEngineMain.modifyOp`:
protected Op modifyOp(Op op)
// Cope with initial bindings.
op = Substitute.substitute(op, initialInput) ;
// Use standard optimizations.
op = super.modifyOp(op) ;
@@ -3,7 +3,7 @@ title: Apache Jena SPARQL APIs
slug: index

Jump to "[Changes](#changes)".
Jump to the "[Changes](#changes)" section.

## Overview

@@ -89,12 +89,10 @@ objects have been removed.

* Deprecate modifying `QueryExecution` after it is built.

* Parameterization for remote queries.
Parameterization - replacing variables by values before sending
a query - makes the query into a template. The same applies to updates.
This is also provided uniformly for local queries and should be used in
preference to the local-only "initial binding" approach which is
similarly but not identical.
* Substitution of variables for concrete values in query and update execution.
This is a form of paramterization that works in both local and remnote usage
(unlike "intial bindings" which are only available for lcoal query execution).
See the [substitution section](#substitution) section below.

* `HttpOp`, using ``, is split into `HttpRDF` for
GET/POST/PUT/DELETE of graphs and datasets and new `HttpOp` for packaged-up
@@ -109,6 +107,41 @@ objects have been removed.
`ModelStore` are the replacement for remote operations. `RDFConnection` and
`RDFLink` provide APIs.
## Substitution
All query and update builders provide operations to uses a query and substitute
variables for concrete RDF terms in the execution
Unlike "initial bindings" substitution is provided in query and update builders
for both local and remote cases.
Substitution is always "replace variable with RDF term" in a query or update
that is correct syntax. This means is does not apply to `INSERT DATA` or `DELETE
DATA` but can be used with `INSERT { ?s ?p ?o } WHERE {}` and
`DELETE { ?s ?p ?o } WHERE {}`.
Full example:
ResultSet resultSet1 = QueryExecution.dataset(dataset)
.query(prefixes+"SELECT * { ?person foaf:name ?name }")
.substitution("name", name1)

Substitution is to be preferred over "initial bindings" because it is clearly
defined and applies to both query and update in both local and remote uses.

"Substitution" and "initial bindings" are similar but not identical.

See also
* [Parameterized Queries](documentation/query/parameterized-sparql-strings.html)
* [Jena Query Builder](

which provide a different ways to build a query.

## <tt>RDFConnection</tt>


0 comments on commit 8590d1e

Please sign in to comment.