Hi there,
> this.conn.load( "book1", model1 );
> this.conn.abort();
Fueski actions are independent transaction and the "this.conn.begin"
only gives a local transaction. The SPARQL protocols don't include
multi-step transaction (it could be added to Fuseki - small matter to
time!).
Think of RDFConnection as "remote first" and it can be used the same way
on local databases.
So prepare the data the app wants locally, as the code is doing, then
have the app decide whether it wants to makes the changes or not.
There is RDF Delta, not part of the Apache Jena project, that allows a
local dataset to be synced with a remote one, and it also includes RDF
patch - both additions and deletions to a dataset. These can be sent to
a Fuseki service that applies them.
https://afs.github.io/rdf-delta/
https://afs.github.io/rdf-delta/rdf-patch.html
Andy
On 27/11/2020 18:08, Jit K wrote:
I have following piece of code to crate triples/graphs in TDB. I need my
program to work with both local and remote RDFConnection.
private void testTransaction() {
this.conn.begin( ReadWrite.WRITE );
try {
// Create a sample Model with few triples
Model model1 = ModelFactory.createDefaultModel();
Resource r1 = model1.createResource(
"http://example.org/book#1" );
r1.addProperty( DC.title, "SPARQL - the book" );
r1.addProperty( DC.description, "A book about SPARQL" );
// Create another sample model
Model model2 = ModelFactory.createDefaultModel();
Resource r2 = model2.createResource(
"http://example.org/book#2" );
r2.addProperty( DC.title, "Advanced techniques for
SPARQL" );
// Add model1 to the Dataset
this.conn.load( "book1", model1 );
// Assuming an error condition, abort the transaction
this.conn.abort();
} finally {
this.conn.end();
}
}
I have noticed following difference in Transactional behavior of Local and
Remote RDFConnection.
For a RDFConnectionLocal, graph "book1" is not found in the dataset when this
function is completed
For a RDFConnectionRemote(Fuseki), even if a transaction is aborted, graph
"book1" gets saved in the dataset and is not rolled back on abort.
My expectation is that, On aborting the transaction, graph "book1" should be
rolled back from the dataset.
This is seen in case of local dataset but not working in case of remote dataset.
I have seen examples that are available with jena distribution but they are all
for local dataset.
Am I missing any concept?
How to implement correct transactional behavior in case of remote dataset?
JK