Search code examples
sparqlrdfjenaowlapache-jena

JENA - Check whether a SPARQL Update Query fails or not


I write the backend for an OWL database and need to check whether the erasure or the insertion of a triple was successful.

What I have got until now looks like that:

String queryUpdate =
/*Update String*/
        UpdateRequest request = UpdateFactory.create(queryUpdate);
        UpdateProcessor proc = UpdateExecutionFactory.create(request, graphStore);
        proc.execute();

So what I need is something like a boolean value from the proc.execute() method.

Does something comparable exist?


Solution

  • Transactions would be a good idea if there is multiple threads access the data. if this is all single-threaded, consistency isn't such a problem.

    What does "succeed" mean? The SPARQL Update was legal and executed or whether the data was changed in some expected way?

    For the former, you get an exception.

    If it is the latter, it is not the job of proc.execute (how would it know?). A useful approach is to conditional insert a triple into the data to record there state. This happens as part of the update.

    ... operation1 ... 
    ;
    ... operation2 ... 
    ;
    INSERT { [] :succeded true }
    WHERE {
        ... test condition ...
    }