public void doRollback(RDFBeanTransaction txn) { txn.rollback(); } }
@Override public boolean isActive() { return transactions[0].isActive(); }
public boolean isRollbackOnly() { return session.getTransaction().isRollbackOnly(); }
public SeedEntityImpl( Configuration configuration, SessionFactory sessionFactory, List<Object> entities) throws IOException { this.persisted = new HashMap<Object, Object>(entities.size()); Session session = sessionFactory.openSession(); RDFBeanTransaction tx = session.beginTransaction(); try { for (Object entity : entities) { replaceReferences(configuration, entity); Object original = session.getByExample(entity); if (original == null) { session.save(entity); } else { persisted.put(entity, original); } } tx.commit(); } catch (Exception e) { logger.error(e.getMessage(), e); tx.rollback(); } finally { session.close(); } }
public void doCommit(Session session, RDFBeanTransaction txn) { RuntimeException commitException = null; try { session.flush(); txn.commit(); } catch (RuntimeException re) { doRollback(txn); commitException = re; } if (commitException != null) { throw commitException; } }
inSession = true; Session session = sessionContext.getCurrentSession(); inTx = session.getTransaction() != null && session.getTransaction().isActive(); result = methodInvocation.proceed(); } catch (Exception e) { if (txn.isRollbackOnly() || isRollbackNecessary(annotation, e, txn)) { doRollback(txn); } else { if (!txn.isRollbackOnly()) { doCommit(session, txn); } else {
@Override public void setRollbackOnly() { this.rollbackOnly = true; for (RDFBeanTransaction tx : transactions) { tx.setRollbackOnly(); } }
@Override public <RT> RT execute(RDFConnectionCallback<RT> operation) { RDFConnection connection = openConnection(); try { RDFBeanTransaction tx = connection.beginTransaction(false, RDFBeanTransaction.TIMEOUT, RDFBeanTransaction.ISOLATION); try { RT retVal = operation.doInConnection(connection); tx.commit(); return retVal; } catch (IOException io) { tx.rollback(); throw new RepositoryException(io); } } finally { connection.close(); } }
private void doCommit(Session session, RDFBeanTransaction txn) throws Exception { Exception commitException = null; try { session.flush(); txn.commit(); } catch (RuntimeException re) { doRollback(txn); commitException = re; } if (commitException != null) { throw commitException; } }
inSession = true; Session session = sessionContext.getCurrentSession(); inTx = session.getTransaction() != null && session.getTransaction().isActive(); invocation.rethrow(); if (!txn.isRollbackOnly()) { transactionalAdvisor.doCommit(session, txn); } else {
public void setRollbackOnly() { session.getTransaction().setRollbackOnly(); }
@Override public <RT> RT execute(RDFConnectionCallback<RT> operation) { RDFConnection connection = openConnection(); try{ RDFBeanTransaction tx = connection.beginTransaction(false, RDFBeanTransaction.TIMEOUT, RDFBeanTransaction.ISOLATION); try{ RT retVal = operation.doInConnection(connection); tx.commit(); return retVal; }catch(IOException io){ tx.rollback(); throw new RepositoryException(io); } }finally{ connection.close(); } }
private void doRollback(RDFBeanTransaction txn) { txn.rollback(); }
@Override public void commit() { if (rollbackOnly) { throw new RepositoryException("Transaction is rollBackOnly"); } try { prepare(); } catch (RuntimeException e) { rollback(); throw new RepositoryException(e); } try { for (RDFBeanTransaction tx : transactions) { tx.commit(); } } finally { connection.cleanUpAfterCommit(); } }
/** * Check if the given transaction object indicates an existing transaction * (that is, a transaction which has already started). * <p> * The result will be evaluated according to the specified propagation * behavior for the new transaction. An existing transaction might get * suspended (in case of PROPAGATION_REQUIRES_NEW), or the new transaction * might participate in the existing one (in case of PROPAGATION_REQUIRED). * <p> * The default implementation returns <code>false</code>, assuming that * participating in existing transactions is generally not supported. * Subclasses are of course encouraged to provide such support. * * @param transaction * transaction object returned by doGetTransaction * @return if there is an existing transaction * @throws TransactionException * in case of system errors * @see #doGetTransaction */ @Override protected boolean isExistingTransaction(Object transaction) { return ((TransactionObject) transaction).getTransaction() != null && ((TransactionObject) transaction).getTransaction().isActive(); }
@Override public <RT> RT execute(RDFConnectionCallback<RT> operation) { RDFConnection connection = openConnection(); try { RDFBeanTransaction tx = connection.beginTransaction(false, RDFBeanTransaction.TIMEOUT, RDFBeanTransaction.ISOLATION); try { RT retVal = operation.doInConnection(connection); tx.commit(); return retVal; } catch (IOException io) { tx.rollback(); throw new RepositoryException(io); } } finally { connection.close(); } }
@Override public void rollback() { try { for (RDFBeanTransaction tx : transactions) { tx.rollback(); } } finally { connection.cleanUpAfterCommit(); } }
tx.commit(); } catch (RuntimeException oe) { throw new TransactionSystemException("error committing transaction", oe);
@Override public void evaluate() throws Throwable { Session session = SessionUtil.openSession(repository, new Locale("fi"), config.value()); RDFBeanTransaction tx = transactional ? session.beginTransaction() : null; try { Field field = target.getClass().getField("session"); field.setAccessible(true); field.set(target, session); base.evaluate(); } finally { if (tx != null) { tx.rollback(); } session.close(); } } };
tx.rollback(); } catch (RuntimeException oe) { throw new TransactionSystemException("error rolling back transaction", oe);