Hi William,

I have compiled your test program and have been able to see the issue you report which has been reported to our development team for comment/resolution. Once I have feedback from them I shall report back to the mailing list with the solution.

Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support

On 29 Aug 2008, at 12:59, William Lee wrote:

Hi all,

I have a question regarding support of transaction when using the Sesame 2 driver on top of 5.0.7. I have a test case which tries to add a statement and then attempt a rollback. The statement still exist after the rollback. I have attached a test case to see whether anyone can shed some light on the transaction support.

Cheers,

Will

package virtuoso.test;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import org.junit.Test;
import org.openrdf.model.URI;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;

import virtuoso.sesame2.driver.VirtuosoRepository;

public class TransactionTestCase {

    @Test
    public void testTransaction() throws Exception {

        Repository repository = null;
        RepositoryConnection connection = null;
        try {
repository = new VirtuosoRepository("jdbc:virtuoso:// localhost:1111", "xxx", "xxx");
            repository.initialize();
            connection = repository.getConnection();

            // disable auto-commit to start a transaction.
            connection.setAutoCommit(false);

URI subject = repository.getValueFactory().createURI ("urn:s"); URI predicate = repository.getValueFactory().createURI ("urn:p"); URI object = repository.getValueFactory().createURI ("urn:o"); URI context = repository.getValueFactory().createURI ("urn:c");

            // The triple should be non-existent before add.
            connection.clear(context);
assertThat(connection.getStatements(subject, predicate, object, false, context).hasNext(), equalTo(false));

            // 1. add the triple.
            connection.add(subject, predicate, object, context);

            // 2. test if the triple now exist.
assertThat(connection.getStatements(subject, predicate, object, false, context).hasNext(), equalTo(true));

            // 3. force a rollback
            connection.rollback();

            // 4. make sure the triple still exist after the commit.
assertThat(connection.getStatements(subject, predicate, object, false, context).hasNext(), equalTo(false));
        } catch (Exception e) {
            fail("not expecting an exception");
        } finally {
            if (connection != null) {
                connection.close();
            }
            if (repository != null) {
                repository.shutDown();
            }
        }

    }
}

---------------------------------------------------------------------- --- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________
Virtuoso-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/virtuoso-devel

Reply via email to