本文整理了Java中org.eclipse.rdf4j.repository.RepositoryConnection.begin
方法的一些代码示例,展示了RepositoryConnection.begin
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryConnection.begin
方法的具体详情如下:
包路径:org.eclipse.rdf4j.repository.RepositoryConnection
类名称:RepositoryConnection
方法名:begin
[英]Begins a new transaction, requiring #commit() or #rollback() to be called to end the transaction. The transaction will use the currently set IsolationLevel for this connection.
[中]开始一个新事务,需要调用#commit()或#rollback()来结束事务。事务将为此连接使用当前设置的隔离级别。
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
@Override
public void begin()
throws RepositoryException
{
getDelegate().begin();
}
代码示例来源:origin: joshsh/sesametools
protected void startTransactionInternal() throws SailException {
try {
repoConnection.begin();
} catch (RepositoryException e) {
throw new SailException(e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
@Override
public void begin(IsolationLevel level)
throws RepositoryException
{
getDelegate().begin(level);
}
代码示例来源:origin: eclipse/rdf4j
@Override
public void begin()
throws RepositoryException
{
getDelegate().begin();
}
代码示例来源:origin: eclipse/rdf4j
@Override
public void begin(IsolationLevel level)
throws RepositoryException
{
getDelegate().begin(level);
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-http-server-spring
/**
* Start the transaction.
*
* @param level
* the {@link IsolationLevel} to use for this transction.
* @throws InterruptedException
* if the transaction thread is interrupted
* @throws ExecutionException
* if an error occurs while starting the transaction.
*/
void begin(IsolationLevel level)
throws InterruptedException, ExecutionException
{
Future<Boolean> result = submit(() -> {
txnConnection.begin(level);
return true;
});
getFromFuture(result);
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-repository-event
@Override
public void begin()
throws RepositoryException
{
getDelegate().begin();
if (activated) {
for (RepositoryConnectionListener listener : listeners) {
listener.begin(getDelegate());
}
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
@Override
public void begin()
throws RepositoryException
{
getDelegate().begin();
if (activated) {
for (RepositoryConnectionListener listener : listeners) {
listener.begin(getDelegate());
}
}
}
代码示例来源:origin: eclipse/rdf4j
@Override
public void begin()
throws RepositoryException
{
getDelegate().begin();
if (activated) {
for (RepositoryConnectionListener listener : listeners) {
listener.begin(getDelegate());
}
}
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-shacl
void fillAddedAndRemovedStatementRepositories() {
addedStatements = getNewMemorySail();
removedStatements = getNewMemorySail();
addedStatementsSet.forEach(stats::added);
removedStatementsSet.forEach(stats::removed);
try (RepositoryConnection connection = addedStatements.getConnection()) {
connection.begin(IsolationLevels.NONE);
addedStatementsSet.stream().filter(statement -> !removedStatementsSet.contains(statement)).forEach(connection::add);
connection.commit();
}
try (RepositoryConnection connection = removedStatements.getConnection()) {
connection.begin(IsolationLevels.NONE);
removedStatementsSet.stream().filter(statement -> !addedStatementsSet.contains(statement)).forEach(connection::add);
connection.commit();
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-shacl
void fillAddedAndRemovedStatementRepositories() {
addedStatements = getNewMemorySail();
removedStatements = getNewMemorySail();
addedStatementsSet.forEach(stats::added);
removedStatementsSet.forEach(stats::removed);
try (RepositoryConnection connection = addedStatements.getConnection()) {
connection.begin(IsolationLevels.NONE);
addedStatementsSet.stream().filter(statement -> !removedStatementsSet.contains(statement)).forEach(connection::add);
connection.commit();
}
try (RepositoryConnection connection = removedStatements.getConnection()) {
connection.begin(IsolationLevels.NONE);
removedStatementsSet.stream().filter(statement -> !addedStatementsSet.contains(statement)).forEach(connection::add);
connection.commit();
}
}
代码示例来源:origin: joshsh/sesametools
@Override
public boolean add(Resource s, IRI p, Value o, Resource... c) {
try {
rc.begin();
rc.add(s, p, o, c);
rc.commit();
return true;
} catch (RepositoryException e) {
throw new RepositoryGraphRuntimeException(e);
}
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-kb
@Override
public KBHandle update(KnowledgeBase kb, UpdateAction aAction)
{
if (kb.isReadOnly()) {
log.warn("Knowledge base [{}] is read only, will not alter!", kb.getName());
return null;
}
KBHandle result = null;
try (RepositoryConnection conn = getConnection(kb)) {
boolean error = true;
try {
conn.begin();
result = aAction.accept(conn);
conn.commit();
error = false;
}
finally {
if (error) {
conn.rollback();
}
}
}
return result;
}
代码示例来源:origin: inception-project/inception
@Override
public KBHandle update(KnowledgeBase kb, UpdateAction aAction)
{
if (kb.isReadOnly()) {
log.warn("Knowledge base [{}] is read only, will not alter!", kb.getName());
return null;
}
KBHandle result = null;
try (RepositoryConnection conn = getConnection(kb)) {
boolean error = true;
try {
conn.begin();
result = aAction.accept(conn);
conn.commit();
error = false;
}
finally {
if (error) {
conn.rollback();
}
}
}
return result;
}
代码示例来源:origin: de.tudarmstadt.ukp.inception.rdf4j/rdf4j-sail-inferencer
public void initialize()
throws SailException
{
super.initialize();
if (sharedSchema) {
return;
}
try (final SchemaCachingRDFSInferencerConnection conn = getConnection()) {
conn.begin();
conn.addAxiomStatements();
List<Statement> tboxStatments = new ArrayList<>();
if (schema != null) {
try (RepositoryConnection schemaConnection = schema.getConnection()) {
schemaConnection.begin();
RepositoryResult<Statement> statements = schemaConnection.getStatements(null, null, null);
tboxStatments = Iterations.stream(statements).peek(conn::processForSchemaCache).collect(
Collectors.toList());
schemaConnection.commit();
}
}
calculateInferenceMaps(conn);
if (schema != null) {
tboxStatments.forEach(statement -> conn.addStatement(statement.getSubject(),
statement.getPredicate(), statement.getObject(), statement.getContext()));
}
conn.commit();
}
}
代码示例来源:origin: eclipse/rdf4j
@Override
public void initialize()
throws RepositoryException
{
super.initialize();
try (RepositoryConnection con = getConnection()) {
if (con.isEmpty()) {
logger.debug("Initializing empty {} repository", ID);
con.begin();
con.setNamespace("rdf", RDF.NAMESPACE);
con.setNamespace("sys", RepositoryConfigSchema.NAMESPACE);
con.commit();
RepositoryConfig repConfig = new RepositoryConfig(ID, TITLE, new SystemRepositoryConfig());
RepositoryConfigUtil.updateRepositoryConfigs(con, repConfig);
}
}
catch (RepositoryConfigException e) {
throw new RepositoryException(e.getMessage(), e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
@Override
public void initialize()
throws RepositoryException
{
super.initialize();
RepositoryConnection con = getConnection();
try {
if (con.isEmpty()) {
logger.debug("Initializing empty {} repository", ID);
con.begin();
con.setNamespace("rdf", RDF.NAMESPACE);
con.setNamespace("sys", RepositoryConfigSchema.NAMESPACE);
con.commit();
RepositoryConfig repConfig = new RepositoryConfig(ID, TITLE, new SystemRepositoryConfig());
RepositoryConfigUtil.updateRepositoryConfigs(con, repConfig);
}
}
catch (RepositoryConfigException e) {
throw new RepositoryException(e.getMessage(), e);
}
finally {
con.close();
}
}
代码示例来源:origin: franzinc/agraph-java-client
@Test
public void testisActive() throws Exception {
assertFalse(testCon.isActive());
testCon.begin();
assertTrue(testCon.isActive());
testCon.add(bob, name, nameBob);
testCon.commit();
// Sesame 2.6 transaction semantics are inverse of Sesame 2.7 transaction semantics.
// Therefore, this test as it passes for 2.6 will fail in 2.7
// So I have commented out below assert statement
// assertFalse(testCon.isActive());
}
代码示例来源:origin: franzinc/agraph-java-client
@Test
public void testBegin() throws Exception {
assertFalse(testCon.isActive());
testCon.begin();
assertTrue(testCon.isActive());
testCon.add(bob, name, nameBob);
testCon.commit();
// Sesame 2.6 transaction semantics are inverse of Sesame 2.7 transaction semantics.
// Therefore, this test as it passes for 2.6 will fail in 2.7
// So I have commented out below assert statement
// assertFalse(testCon.isActive());
}
代码示例来源:origin: franzinc/agraph-java-client
@Test
public void testBeginRollback() throws Exception {
assertFalse(testCon.isActive());
testCon.begin();
assertTrue(testCon.isActive());
testCon.add(bob, name, nameBob);
testCon.rollback();
// Sesame 2.6 transaction semantics are inverse of Sesame 2.7 transaction semantics.
// Therefore, this test as it passes for 2.6 will fail in 2.7
// So I have commented out below assert statement
// assertFalse(testCon.isActive());
}
内容来源于网络,如有侵权,请联系作者删除!