org.openrdf.repository.RepositoryConnection.isAutoCommit()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(118)

本文整理了Java中org.openrdf.repository.RepositoryConnection.isAutoCommit方法的一些代码示例,展示了RepositoryConnection.isAutoCommit的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RepositoryConnection.isAutoCommit方法的具体详情如下:
包路径:org.openrdf.repository.RepositoryConnection
类名称:RepositoryConnection
方法名:isAutoCommit

RepositoryConnection.isAutoCommit介绍

暂无

代码示例

代码示例来源:origin: org.openrdf.elmo/elmo-repository

@Override
public boolean isAutoCommit()
  throws RepositoryException
{
  RepositoryConnection conn = threadContext.get();
  return conn == null || conn.isAutoCommit();
}

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

public boolean isActive() {
  try {
    return !conn.isAutoCommit();
  } catch (RepositoryException e) {
    throw new PersistenceException(e);
  }
}

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

public void merge(Object source) {
  if (source instanceof java.util.List) {
    RepositoryConnection conn = manager.getConnection();
    try {
      boolean autoCommit = conn.isAutoCommit();
      if (autoCommit)
        conn.setAutoCommit(false);
      java.util.List list = (java.util.List) source;
      int size = list.size();
      for (int i=0,n=size; i<n; i++) {
        assign(i, list.get(i));
      }
      if (_size > UNKNOWN && _size < size)
        _size = size;
      if (autoCommit)
        conn.setAutoCommit(true);
    } catch (RepositoryException e) {
      throw new ElmoPersistException(e);
    }
  }
}

代码示例来源:origin: org.semweb4j/rdf2go.impl.sesame20

/**
 * Locking a RepositoryModel disables auto-commit mode and starts a new
 * transaction, which is left open until this RepositoryModel is unlocked.
 */
public synchronized void lock()
  throws LockException
{
  if (isLocked()) {
    return;
  }
  try {
    // mark this model as locked
    locked = true;
    // disable auto-commit
    autocommitBeforeLock = connection.isAutoCommit();
    connection.setAutoCommit(false);
    // flush everything that has not been commited yet
    connection.commit();
  }
  catch (RepositoryException e) {
    throw new LockException(e);
  }
}

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

public void set(Object o) {
  RepositoryConnection conn = manager.getConnection();
  try {
    boolean autoCommit = conn.isAutoCommit();
    if (autoCommit)
      conn.setAutoCommit(false);
    if (resource.equals(RDF.NIL)) {
      // size == 0
      throw new NoSuchElementException();
    } else if (list.equals(RDF.NIL)) {
      // index = size
      throw new NoSuchElementException();
    } else {
      Value first = getFirst(list);
      removeStatements(list, RDF.FIRST, first);
      if (o != null) {
        Value obj = manager.getValue(o);
        addStatement(list, RDF.FIRST, obj);
      }
    }
    if (autoCommit)
      conn.setAutoCommit(true);
    refresh();
  } catch (RepositoryException e) {
    throw new ElmoPersistException(e);
  }
}

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

public void setAll(Set<E> set) {
  if (this == set)
    return;
  if (set == null) {
    clear();
    return;
  }
  Set<E> c = new HashSet<E>(set);
  RepositoryConnection conn = getConnection();
  try {
    boolean autoCommit = conn.isAutoCommit();
    if (autoCommit)
      conn.setAutoCommit(false);
    if (!cached || !cache.isEmpty()) {
      clear();
    }
    addAll(c);
    if (autoCommit)
      conn.setAutoCommit(true);
  } catch (RepositoryException e) {
    throw new ElmoPersistException(e);
  }
  refreshCache();
}

代码示例来源:origin: org.openrdf.elmo/elmo-repository

/**
 * After this object has recorded changes to a connection, it can be
 * repeated with this method. This RepositoryConnection does not have to be
 * the same connection that this object was attached to.
 * 
 * @param conn
 * @throws RepositoryException
 */
public void redo(RepositoryConnection conn) throws RepositoryException {
  if (exc != null)
    throw exc;
  stopListening();
  synchronized (active) {
    boolean autoCommit = conn.isAutoCommit();
    conn.setAutoCommit(false);
    if (committed != null)
      redo(committed, conn);
    redo(active, conn);
    conn.setAutoCommit(autoCommit);
  }
}

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

public void setSingle(E o) {
  if (o == null) {
    clear();
  } else {
    RepositoryConnection conn = getConnection();
    try {
      boolean autoCommit = conn.isAutoCommit();
      if (autoCommit)
        conn.setAutoCommit(false);
      if (!cached || !cache.isEmpty()) {
        clear();
      }
      add(o);
      if (autoCommit)
        conn.setAutoCommit(true);
    } catch (RepositoryException e) {
      throw new ElmoPersistException(e);
    }
  }
}

代码示例来源:origin: org.openrdf.elmo/elmo-repository

/**
 * After this object has recorded changes to a connection, it can be
 * reverted with this method. This RepositoryConnection does not have to be
 * the same connection that this object was attached to.
 * 
 * @param conn
 * @throws RepositoryException
 */
public void undo(RepositoryConnection conn) throws RepositoryException {
  if (exc != null)
    throw exc;
  stopListening();
  synchronized (active) {
    boolean autoCommit = conn.isAutoCommit();
    conn.setAutoCommit(false);
    undo(active, conn);
    if (committed != null)
      undo(committed, conn);
    conn.setAutoCommit(autoCommit);
  }
}

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

@Override
public Object set(int index, Object obj) {
  RepositoryConnection conn = manager.getConnection();
  try {
    boolean autoCommit = conn.isAutoCommit();
    if (autoCommit)
      conn.setAutoCommit(false);
    Value value = getAndSet(index, obj);
    Object old = createInstance(value);
    if (autoCommit)
      conn.setAutoCommit(true);
    return old;
  } catch (RepositoryException e) {
    throw new ElmoPersistException(e);
  }
}

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

public boolean addAll(Collection<? extends E> c) {
  RepositoryConnection conn = getConnection();
  boolean modified = false;
  try {
    boolean autoCommit = conn.isAutoCommit();
    if (autoCommit)
      conn.setAutoCommit(false);
    for (E o : c)
      if (add(o))
        modified = true;
    if (autoCommit)
      conn.setAutoCommit(true);
  } catch (RepositoryException e) {
    throw new ElmoPersistException(e);
  }
  refreshEntity();
  return modified;
}

代码示例来源:origin: org.openrdf.sesame/sesame-http-server-spring

if (!repositoryCon.isAutoCommit()) {
  repositoryCon.setAutoCommit(true);

代码示例来源:origin: org.semweb4j/rdf2go.impl.sesame20

boolean autocommitBefore = connection.isAutoCommit();
connection.setAutoCommit(false);
try {

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

public boolean removeAll(Collection<?> c) {
  RepositoryConnection conn = getConnection();
  boolean modified = false;
  try {
    boolean autoCommit = conn.isAutoCommit();
    if (autoCommit)
      conn.setAutoCommit(false);
    for (Object o : c)
      if (remove(o))
        modified = true;
    if (autoCommit)
      conn.setAutoCommit(true);
  } catch (RepositoryException e) {
    throw new ElmoPersistException(e);
  }
  refreshCache();
  refreshEntity();
  return modified;
}

代码示例来源:origin: org.semweb4j/rdf2go.impl.sesame20

@Override
public void removeAll()
  throws ModelRuntimeException
{
  if (this.isLocked()) {
    throw new ModelRuntimeException("Model is locked, cannot perform an update.");
  }
  // do not auto-commit
  assertModel();
  try {
    boolean autocommitBefore = connection.isAutoCommit();
    connection.setAutoCommit(false);
    // remove all
    connection.clear();
    connection.setAutoCommit(autocommitBefore);
  }
  catch (RepositoryException x) {
    throw new ModelRuntimeException(x);
  }
}

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

@Override
public void add(int index, Object obj) {
  RepositoryConnection conn = manager.getConnection();
  try {
    boolean autoCommit = conn.isAutoCommit();
    if (autoCommit)
      conn.setAutoCommit(false);
    for (int i = size() - 1; i >= index; i--) {
      replace(i + 1, get(i));
    }
    replace(index, obj);
    if (_size > UNKNOWN)
      _size++;
    if (autoCommit)
      conn.setAutoCommit(true);
  } catch (RepositoryException e) {
    throw new ElmoPersistException(e);
  }
}

代码示例来源:origin: org.semweb4j/rdf2go.impl.sesame20

boolean autocommitBefore = this.connection.isAutoCommit();
this.connection.setAutoCommit(false);
try {

代码示例来源:origin: org.semweb4j/rdf2go.impl.sesame20

try {
  boolean autocommitBefore = this.connection.isAutoCommit();
  this.connection.setAutoCommit(false);
  try {

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

public boolean retainAll(Collection<?> c) {
  RepositoryConnection conn = getConnection();
  boolean modified = false;
  try {
    boolean autoCommit = conn.isAutoCommit();
    if (autoCommit)
      conn.setAutoCommit(false);
    ElmoIteration<Statement, E> e = getElmoIteration();
    try {
      while (e.hasNext()) {
        if (!c.contains(e.next())) {
          e.remove();
          modified = true;
        }
      }
    } finally {
      e.close();
    }
    if (autoCommit)
      conn.setAutoCommit(true);
  } catch (RepositoryException e) {
    throw new ElmoPersistException(e);
  }
  refreshCache();
  refreshEntity();
  return modified;
}

代码示例来源:origin: org.openrdf.elmo/elmo-sesame

@Override
public Object remove(int index) {
  RepositoryConnection conn = manager.getConnection();
  try {
    boolean autoCommit = conn.isAutoCommit();
    conn.setAutoCommit(false);
    Object obj = get(index);
    int size = size();
    for (int i = index; i < size - 1; i++) {
      replace(i, get(i + 1));
    }
    URI pred = getMemberPredicate(size - 1);
    ElmoIteration<Statement, Value> stmts = getStatements(pred);
    try {
      while (stmts.hasNext()) {
        stmts.next();
        stmts.remove();
      }
    } finally {
      stmts.close();
    }
    if (_size > UNKNOWN)
      _size--;
    conn.setAutoCommit(autoCommit);
    return obj;
  } catch (RepositoryException e) {
    throw new ElmoPersistException(e);
  }
}

相关文章

微信公众号

最新文章

更多