tags:

views:

24

answers:

1

I'm trying to add some simple statements to a Sesame repository, like so:

    RepositoryConnection connection = repository.connection
    connection.autoCommit = false
    try {
        ValueFactory vf = repository.getValueFactory()
        def dummyS = vf.createURI("http://some/uri")
        def dummyP = vf.createURI("http://some/uri/hasItem")
        uris?.each { uri ->
            connection.add(listS, listP, vf.createURI(uri))
        }
        def stmts = connection.getStatements(listS, null, null, true) ...

This works great when executed against a local SailRepository using NativeStore. But when hooking this up to an HTTPRepository hosted on a different server, the 'add' appears to fail silently. No exception is thrown, but the returned stmts is empty.

Anybody have any ideas what could be causing this? Thanks in advance!

A: 

The reason this fails is that you are using autoCommit=false. In a local setting, Sesame's transaction isolation takes care that even when not yet committed, added data is visible when querying on the same connection.

However, the HTTPRepository class does not support transaction isolation: the added triples are not visible until you have committed. So, to fix, add:

connection.commit(); 

before the getStatements() call and you should be fine.

Jeen Broekstra