javax.transaction.TransactionManager.setRollbackOnly()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(198)

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

TransactionManager.setRollbackOnly介绍

[英]Mark the transaction associated with the calling thread for rollback only.
[中]将与调用线程关联的事务标记为仅回滚。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public void setRollbackOnly() throws SystemException {
  this.transactionManager.setRollbackOnly();
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public void setRollbackOnly() throws SystemException {
  this.transactionManager.setRollbackOnly();
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public void setRollbackOnly() throws IllegalStateException, SystemException {
  mgr.setRollbackOnly();
}

代码示例来源:origin: apache/geode

/**
 * Calls setRollbackOnly() of the transaction manager owning this user transaction
 *
 * @see javax.transaction.UserTransaction#setRollbackOnly()
 */
@Override
public void setRollbackOnly() throws IllegalStateException, SystemException {
 tm.setRollbackOnly();
}

代码示例来源:origin: org.springframework/spring-tx

@Override
public void setRollbackOnly() throws SystemException {
  this.transactionManager.setRollbackOnly();
}

代码示例来源:origin: org.springframework/spring-tx

@Override
public void setRollbackOnly() throws SystemException {
  this.transactionManager.setRollbackOnly();
}

代码示例来源:origin: Activiti/Activiti

private void doRollback(boolean isNew, Throwable originalException) {
 Throwable rollbackEx = null;
 try {
  if (isNew) {
   transactionManager.rollback();
  } else {
   transactionManager.setRollbackOnly();
  }
 } catch (SystemException e) {
  LOGGER.debug("Error when rolling back transaction", e);
 } catch (RuntimeException e) {
  rollbackEx = e;
  throw e;
 } catch (Error e) {
  rollbackEx = e;
  throw e;
 } finally {
  if (rollbackEx != null && originalException != null) {
   LOGGER.error("Error when rolling back transaction, original exception was:", originalException);
  }
 }
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public void markRollbackOnly() {
  try {
    transactionManager.setRollbackOnly();
  }
  catch (SystemException e) {
    throw new TransactionException( "Could not set transaction to rollback only", e );
  }
}

代码示例来源:origin: wildfly/wildfly

public void setRollbackOnly() throws IllegalStateException {
  if (isBeanManagedTransaction()) {
    throw EjbLogger.ROOT_LOGGER.failToCallSetRollbackOnlyOnNoneCMB();
  }
  try {
    // get the transaction manager
    TransactionManager tm = getTransactionManager();
    // check if there's a tx in progress. If not, then it's an error to call setRollbackOnly()
    if (tm.getTransaction() == null) {
      throw EjbLogger.ROOT_LOGGER.failToCallSetRollbackOnlyWithNoTx();
    }
    // set rollback
    tm.setRollbackOnly();
  } catch (SystemException se) {
    EjbLogger.ROOT_LOGGER.setRollbackOnlyFailed(se);
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void doRollback(boolean isNew) {
 try {
  if (isNew) {
   transactionManager.rollback();
  } else {
   transactionManager.setRollbackOnly();
  }
 } catch (SystemException e) {
  LOG.exceptionWhileRollingBackTransaction(e);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void doRollback(boolean isNew) {
 try {
  if (isNew) {
   transactionManager.rollback();
  } else {
   transactionManager.setRollbackOnly();
  }
 } catch (SystemException e) {
  LOG.exceptionWhileRollingBackTransaction(e);
 }
}

代码示例来源:origin: org.exoplatform.kernel/exo.kernel.component.common

/**
 * {@inheritDoc}
 */
public void setRollbackOnly() throws IllegalStateException, SystemException
{
  tm.setRollbackOnly();
}

代码示例来源:origin: com.haulmont.thirdparty/eclipselink

/**
 * INTERNAL:
 * Mark the external transaction for rollback.
 */
protected void markTransactionForRollback_impl() throws Exception {
  getTransactionManager().setRollbackOnly();
}

代码示例来源:origin: org.lastaflute/lasta-di

public static void setRollbackOnly(TransactionManager tm) throws LjtSystemRuntimeException {
    try {
      tm.setRollbackOnly();
    } catch (SystemException e) {
      throw new LjtSystemRuntimeException(e);
    }
  }
}

代码示例来源:origin: com.atomikos/transactions-jta

/**
 * @see javax.transaction.UserTransaction
 */
public void setRollbackOnly () throws IllegalStateException,
    SystemException
{
  checkSetup ();
  txmgr_.setRollbackOnly ();
}

代码示例来源:origin: bonitasoft/bonita-engine

@Override
public void setRollbackOnly() throws STransactionException {
  try {
    txManager.setRollbackOnly();
  } catch (final IllegalStateException | SystemException e) {
    throw new STransactionException(e);
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testMarkAsRollbackAfterMods() throws Exception {
 TransactionManager tm = TestingUtil.getTransactionManager(cache);
 assert tm != null;
 tm.begin();
 cache.put("k", "v");
 assert cache.get("k").equals("v");
 tm.setRollbackOnly();
 expectException(RollbackException.class, () -> tm.commit());
 assert tm.getTransaction() == null : "There should be no transaction in scope anymore!";
 assert cache.get("k") == null : "Expected a null but was " + cache.get("k");
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testMarkAsRollbackBeforeMods() throws Exception {
   TransactionManager tm = TestingUtil.getTransactionManager(cache);
   assert tm != null;
   tm.begin();
   tm.setRollbackOnly();
   expectException(CacheException.class, IllegalStateException.class, () -> cache.put("k", "v"));
   expectException(RollbackException.class, () -> tm.commit());

   assert tm.getTransaction() == null : "There should be no transaction in scope anymore!";
   assert cache.get("k") == null : "Expected a null but was " + cache.get("k");
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testSizeInExplicitTx() throws Exception {
 assertEquals(0, cache.size());
 cache.put("k", "v");
 TransactionManager tm = TestingUtil.getTransactionManager(cache);
 withTx(tm, () -> {
   assertEquals(1, cache.size());
   tm.setRollbackOnly();
   return null;
 });
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testSizeInExplicitTxWithModification() throws Exception {
 assertEquals(0, cache.size());
 cache.put("k1", "v1");
 TransactionManager tm = TestingUtil.getTransactionManager(cache);
 withTx(tm, () -> {
   assertNull(cache.put("k2", "v2"));
   assertEquals(2, cache.size());
   tm.setRollbackOnly();
   return null;
 });
}

相关文章