Interface RepositoryConnection

All Superinterfaces:
AutoCloseable
All Known Subinterfaces:
DelegatingRepositoryConnection, InterceptingRepositoryConnection, NotifyingRepositoryConnection
All Known Implementing Classes:
AbstractRepositoryConnection, CachingRepositoryConnection, ContextAwareConnection, DatasetRepositoryConnection, EndpointBase.ManagedRepositoryConnection, FedXRepositoryConnection, InterceptingRepositoryConnectionWrapper, LoggingRepositoryConnection, NotifyingRepositoryConnectionWrapper, PooledRepositoryConnection, RepositoryConnectionWrapper, SailRepositoryConnection, SPARQLConnection, TransactionalRepositoryConnection

public interface RepositoryConnection extends AutoCloseable
Main interface for updating data in and performing queries on an RDF4J Repository.

By default, a RepositoryConnection is in auto-commit mode, meaning that each operation corresponds to a single transaction on the underlying store. Multiple operations can be bundled in a single transaction by using begin() and commit/ rollback, which may improve performance considerably when dealing with many thousands of statements. Care should be taking to always properly close a RepositoryConnection after one is finished with it, to free up resources and avoid unnecessary locks.

RepositoryConnection is not guaranteed to be thread-safe. The recommended access pattern in a multithreaded application is to ensure that each thread creates/uses its own RepositoryConnections (which can be obtained from a shared Repository).

Several methods take a vararg argument that optionally specifies one or more contexts (named graphs) on which the method should operate. A vararg parameter is optional, it can be completely left out of the method call, in which case a method either operates on a provided statements context (if one of the method parameters is a statement or collection of statements), or operates on the repository as a whole, completely ignoring context. A vararg argument may also be 'null' (cast to Resource) meaning that the method operates on those statements which have no associated context only.

Examples:

 
 // Ex 1: this method retrieves all statements that appear in either context1 or
 // context2, or both.
 RepositoryConnection.getStatements(null, null, null, true, context1, context2);

 // Ex 2: this method retrieves all statements that appear in the repository
 // (regardless of context).
 RepositoryConnection.getStatements(null, null, null, true);

 // Ex 3: this method retrieves all statements that have no associated context in
 // the repository.
 // Observe that this is not equivalent to the previous method call.
 RepositoryConnection.getStatements(null, null, null, true, (Resource) null);

 // Ex 4: this method adds a statement to the store. If the statement object
 // itself has a context (i.e. statement.getContext() != null) the statement is added
 // to that context. Otherwise, it is added without any associated context.
 RepositoryConnection.add(statement);

 // Ex 5: this method adds a statement to context1 in the store. It completely
 // ignores any context the statement itself has.
 RepositoryConnection.add(statement, context1);
 
 
Author:
Arjohn Kampman, Jeen Broekstra
See Also: