Hi,

I'm attempting to programmatically construct the various forms of sparql
queries using Jena.

I can construct SELECT queries easily enough by composing algebraic Ops
together. I convert them to queries using OpAsQuery, and then pass the
resulting Query object directly to QueryExecutionFactory. This produces the
expected results.

However, I've had a harder time understanding how to incorporate algebraic
Ops into CONSTRUCT and UPDATE queries. The only solution I've found so far
is via the various query builder classes (ConstructBuilder, UpdateBuilder,
etc...). After converting the Ops to a Query using OpAsQuery, I wrap the
Queries as a WhereHandler, and pass the WhereHandler into the the query
builder using builder.addALL(...) or builder.getWhereHandler().addAll(...).
I then add some construct, install or delete triples to get the final
Query. This Query is then run via QueryExecutionFactory.

MAIN QUESTION: What is the recommended way to add algebraic Ops (that
represent the where clause) to CONSTRUCT or UPDATE queries?

My approach produces queries that usually work, but I'm occasionally seeing
some odd behaviour. For example, certain more complex construct queries
don't always return the expected results: but serialize the Query object to
a sparql file, read it back, and then run via QueryExecutionFactory, and
suddenly it returns the expected construction.

Thanks for all your time and effort!

Zalan

Reply via email to