Java Code Examples for org.springframework.transaction.support.DefaultTransactionStatus#isDebug()

The following examples show how to use org.springframework.transaction.support.DefaultTransactionStatus#isDebug() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JdoTransactionManager.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void doCommit(DefaultTransactionStatus status) {
	JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Committing JDO transaction on PersistenceManager [" +
				txObject.getPersistenceManagerHolder().getPersistenceManager() + "]");
	}
	try {
		Transaction tx = txObject.getPersistenceManagerHolder().getPersistenceManager().currentTransaction();
		tx.commit();
	}
	catch (JDOException ex) {
		// Assumably failed to flush changes to database.
		throw convertJdoAccessException(ex);
	}
}
 
Example 2
Source File: JmsTransactionManager.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
protected void doRollback(DefaultTransactionStatus status) {
	JmsTransactionObject txObject = (JmsTransactionObject) status.getTransaction();
	Session session = txObject.getResourceHolder().getOriginalSession();
	if (session != null) {
		try {
			if (status.isDebug()) {
				logger.debug("Rolling back JMS transaction on Session [" + session + "]");
			}
			session.rollback();
		}
		catch (JMSException ex) {
			throw new TransactionSystemException("Could not roll back JMS transaction", ex);
		}
	}
}
 
Example 3
Source File: DataSourceTransactionManager.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void doRollback(DefaultTransactionStatus status) {
	DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
	Connection con = txObject.getConnectionHolder().getConnection();
	if (status.isDebug()) {
		logger.debug("Rolling back JDBC transaction on Connection [" + con + "]");
	}
	try {
		con.rollback();
	}
	catch (SQLException ex) {
		throw new TransactionSystemException("Could not roll back JDBC transaction", ex);
	}
}
 
Example 4
Source File: WebSphereUowTransactionManager.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
	DefaultTransactionStatus status = prepareTransactionStatus(
			this.definition, (this.actualTransaction ? this : null),
			this.newTransaction, this.newSynchronization, this.debug, null);
	try {
		this.result = this.callback.doInTransaction(status);
		triggerBeforeCommit(status);
	}
	catch (Throwable ex) {
		this.exception = ex;
		uowManager.setRollbackOnly();
	}
	finally {
		if (status.isLocalRollbackOnly()) {
			if (status.isDebug()) {
				logger.debug("Transactional code has requested rollback");
			}
			uowManager.setRollbackOnly();
		}
		triggerBeforeCompletion(status);
		if (status.isNewSynchronization()) {
			List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations();
			TransactionSynchronizationManager.clear();
			if (!synchronizations.isEmpty()) {
				uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
			}
		}
	}
}
 
Example 5
Source File: DataSourceTransactionManager.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
	DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Setting JDBC transaction [" + txObject.getConnectionHolder().getConnection() +
				"] rollback-only");
	}
	txObject.setRollbackOnly();
}
 
Example 6
Source File: WebSphereUowTransactionManager.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
	DefaultTransactionStatus status = prepareTransactionStatus(
			this.definition, (this.actualTransaction ? this : null),
			this.newTransaction, this.newSynchronization, this.debug, null);
	try {
		this.result = this.callback.doInTransaction(status);
		triggerBeforeCommit(status);
	}
	catch (Throwable ex) {
		this.exception = ex;
		uowManager.setRollbackOnly();
	}
	finally {
		if (status.isLocalRollbackOnly()) {
			if (status.isDebug()) {
				logger.debug("Transactional code has requested rollback");
			}
			uowManager.setRollbackOnly();
		}
		triggerBeforeCompletion(status);
		if (status.isNewSynchronization()) {
			List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations();
			TransactionSynchronizationManager.clear();
			if (!synchronizations.isEmpty()) {
				uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
			}
		}
	}
}
 
Example 7
Source File: DataSourceTransactionManager.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void doRollback(DefaultTransactionStatus status) {
	DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
	Connection con = txObject.getConnectionHolder().getConnection();
	if (status.isDebug()) {
		logger.debug("Rolling back JDBC transaction on Connection [" + con + "]");
	}
	try {
		con.rollback();
	}
	catch (SQLException ex) {
		throw new TransactionSystemException("Could not roll back JDBC transaction", ex);
	}
}
 
Example 8
Source File: HibernateTransactionManager.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
	HibernateTransactionObject txObject = (HibernateTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Setting Hibernate transaction on Session [" +
				txObject.getSessionHolder().getSession() + "] rollback-only");
	}
	txObject.setRollbackOnly();
}
 
Example 9
Source File: CciLocalTransactionManager.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
	CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Setting CCI local transaction [" + txObject.getConnectionHolder().getConnection() +
				"] rollback-only");
	}
	txObject.getConnectionHolder().setRollbackOnly();
}
 
Example 10
Source File: PostgreSqlTransactionManager.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void doCommit(DefaultTransactionStatus status) {
  MolgenisTransaction transaction = (MolgenisTransaction) status.getTransaction();
  if (LOG.isDebugEnabled()) {
    LOG.debug("Commit transaction [{}]", transaction.getId());
  }

  DefaultTransactionStatus jpaTransactionStatus =
      new DefaultTransactionStatus(
          transaction.getDataSourceTransaction(),
          status.isNewTransaction(),
          status.isNewSynchronization(),
          status.isReadOnly(),
          status.isDebug(),
          status.getSuspendedResources());

  if (!status.isReadOnly()) {
    transactionListeners.forEach(j -> j.commitTransaction(transaction.getId()));
  }

  try {
    super.doCommit(jpaTransactionStatus);
  } catch (TransactionException e) {
    throw translateTransactionException(e);
  }

  if (!status.isReadOnly()) {
    transactionListeners.forEach(j -> j.afterCommitTransaction(transaction.getId()));
  }
}
 
Example 11
Source File: DataSourceTransactionManager.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void doCommit(DefaultTransactionStatus status) {
	DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
	Connection con = txObject.getConnectionHolder().getConnection();
	if (status.isDebug()) {
		logger.debug("Committing JDBC transaction on Connection [" + con + "]");
	}
	try {
		con.commit();
	}
	catch (SQLException ex) {
		throw new TransactionSystemException("Could not commit JDBC transaction", ex);
	}
}
 
Example 12
Source File: LocalTransactionManager.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
	JcrTransactionObject txObject = (JcrTransactionObject) status
			.getTransaction();
	if (status.isDebug()) {
		LOG.debug("Setting JCR transaction on session ["
				+ txObject.getSessionHolder().getSession()
				+ "] rollback-only");
	}
	txObject.setRollbackOnly();
}
 
Example 13
Source File: HibernateTransactionManager.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
	HibernateTransactionObject txObject = (HibernateTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Setting Hibernate transaction on Session [" +
				txObject.getSessionHolder().getSession() + "] rollback-only");
	}
	txObject.setRollbackOnly();
}
 
Example 14
Source File: JdoTransactionManager.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
	JdoTransactionObject txObject = (JdoTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Setting JDO transaction on PersistenceManager [" +
				txObject.getPersistenceManagerHolder().getPersistenceManager() + "] rollback-only");
	}
	txObject.setRollbackOnly();
}
 
Example 15
Source File: DataSourceTransactionManager.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void doRollback(DefaultTransactionStatus status) {
	DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
	Connection con = txObject.getConnectionHolder().getConnection();
	if (status.isDebug()) {
		logger.debug("Rolling back JDBC transaction on Connection [" + con + "]");
	}
	try {
		con.rollback();
	}
	catch (SQLException ex) {
		throw new TransactionSystemException("Could not roll back JDBC transaction", ex);
	}
}
 
Example 16
Source File: SpringTransactionManager.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override protected void doRollback(DefaultTransactionStatus status) throws TransactionException {
    IgniteTransactionObject txObj = (IgniteTransactionObject)status.getTransaction();
    Transaction tx = txObj.getTransactionHolder().getTransaction();

    if (status.isDebug() && log.isDebugEnabled())
        log.debug("Rolling back Ignite transaction: " + tx);

    try {
        tx.rollback();
    }
    catch (IgniteException e) {
        throw new TransactionSystemException("Could not rollback Ignite transaction", e);
    }
}
 
Example 17
Source File: CciLocalTransactionManager.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
	CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Setting CCI local transaction [" + txObject.getConnectionHolder().getConnection() +
				"] rollback-only");
	}
	txObject.getConnectionHolder().setRollbackOnly();
}
 
Example 18
Source File: WebSphereUowTransactionManager.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void run() {
	UOWManager uowManager = obtainUOWManager();
	DefaultTransactionStatus status = prepareTransactionStatus(
			this.definition, (this.actualTransaction ? this : null),
			this.newTransaction, this.newSynchronization, this.debug, null);
	try {
		this.result = this.callback.doInTransaction(status);
		triggerBeforeCommit(status);
	}
	catch (Throwable ex) {
		this.exception = ex;
		if (status.isDebug()) {
			logger.debug("Rolling back on application exception from transaction callback", ex);
		}
		uowManager.setRollbackOnly();
	}
	finally {
		if (status.isLocalRollbackOnly()) {
			if (status.isDebug()) {
				logger.debug("Transaction callback has explicitly requested rollback");
			}
			uowManager.setRollbackOnly();
		}
		triggerBeforeCompletion(status);
		if (status.isNewSynchronization()) {
			List<TransactionSynchronization> synchronizations = TransactionSynchronizationManager.getSynchronizations();
			TransactionSynchronizationManager.clear();
			if (!synchronizations.isEmpty()) {
				uowManager.registerInterposedSynchronization(new JtaAfterCompletionSynchronization(synchronizations));
			}
		}
	}
}
 
Example 19
Source File: CciLocalTransactionManager.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void doSetRollbackOnly(DefaultTransactionStatus status) {
	CciLocalTransactionObject txObject = (CciLocalTransactionObject) status.getTransaction();
	if (status.isDebug()) {
		logger.debug("Setting CCI local transaction [" + txObject.getConnectionHolder().getConnection() +
				"] rollback-only");
	}
	txObject.getConnectionHolder().setRollbackOnly();
}
 
Example 20
Source File: DataSourceTransactionManager.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
protected void doRollback(DefaultTransactionStatus status) {
	DataSourceTransactionObject txObject = (DataSourceTransactionObject) status.getTransaction();
	Connection con = txObject.getConnectionHolder().getConnection();
	if (status.isDebug()) {
		logger.debug("Rolling back JDBC transaction on Connection [" + con + "]");
	}
	try {
		con.rollback();
	}
	catch (SQLException ex) {
		throw new TransactionSystemException("Could not roll back JDBC transaction", ex);
	}
}