本文整理汇总了Java中org.springframework.transaction.IllegalTransactionStateException类的典型用法代码示例。如果您正苦于以下问题:Java IllegalTransactionStateException类的具体用法?Java IllegalTransactionStateException怎么用?Java IllegalTransactionStateException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IllegalTransactionStateException类属于org.springframework.transaction包,在下文中一共展示了IllegalTransactionStateException类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: commit
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
/**
* This implementation of commit handles participating in existing
* transactions and programmatic rollback requests.
* Delegates to {@code isRollbackOnly}, {@code doCommit}
* and {@code rollback}.
* @see org.springframework.transaction.TransactionStatus#isRollbackOnly()
* @see #doCommit
* @see #rollback
*/
@Override
public final void commit(TransactionStatus status) throws TransactionException {
if (status.isCompleted()) {
throw new IllegalTransactionStateException(
"Transaction is already completed - do not call commit or rollback more than once per transaction");
}
DefaultTransactionStatus defStatus = (DefaultTransactionStatus) status;
if (defStatus.isLocalRollbackOnly()) {
if (defStatus.isDebug()) {
logger.debug("Transactional code has requested rollback");
}
processRollback(defStatus);
return;
}
if (!shouldCommitOnGlobalRollbackOnly() && defStatus.isGlobalRollbackOnly()) {
if (defStatus.isDebug()) {
logger.debug("Global transaction is marked as rollback-only but transactional code requested commit");
}
processRollback(defStatus);
// Throw UnexpectedRollbackException only at outermost transaction boundary
// or if explicitly asked to.
if (status.isNewTransaction() || isFailEarlyOnGlobalRollbackOnly()) {
throw new UnexpectedRollbackException(
"Transaction rolled back because it has been marked as rollback-only");
}
return;
}
processCommit(defStatus);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:41,代码来源:AbstractPlatformTransactionManager.java
示例2: propagationMandatoryFailsInCaseOfNoExistingTransaction
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
@Test
public void propagationMandatoryFailsInCaseOfNoExistingTransaction() {
MockUOWManager manager = new MockUOWManager();
WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager(manager);
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_MANDATORY);
try {
ptm.execute(definition, new TransactionCallback<String>() {
@Override
public String doInTransaction(TransactionStatus status) {
return "result";
}
});
fail("Should have thrown IllegalTransactionStateException");
}
catch (IllegalTransactionStateException ex) {
// expected
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:WebSphereUowTransactionManagerTests.java
示例3: propagationNeverFailsInCaseOfExistingTransaction
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
@Test
public void propagationNeverFailsInCaseOfExistingTransaction() {
MockUOWManager manager = new MockUOWManager();
manager.setUOWStatus(UOWManager.UOW_STATUS_ACTIVE);
WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager(manager);
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_NEVER);
try {
ptm.execute(definition, new TransactionCallback<String>() {
@Override
public String doInTransaction(TransactionStatus status) {
return "result";
}
});
fail("Should have thrown IllegalTransactionStateException");
}
catch (IllegalTransactionStateException ex) {
// expected
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:WebSphereUowTransactionManagerTests.java
示例4: testPropagationMandatoryFailsInCaseOfNoExistingTransaction
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
public void testPropagationMandatoryFailsInCaseOfNoExistingTransaction() {
MockUOWManager manager = new MockUOWManager();
WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager(manager);
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_MANDATORY);
try {
ptm.execute(definition, new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
return "result";
}
});
fail("Should have thrown IllegalTransactionStateException");
}
catch (IllegalTransactionStateException ex) {
// expected
}
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:20,代码来源:WebSphereUowTransactionManagerTests.java
示例5: testPropagationNeverFailsInCaseOfExistingTransaction
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
public void testPropagationNeverFailsInCaseOfExistingTransaction() {
MockUOWManager manager = new MockUOWManager();
manager.setUOWStatus(UOWManager.UOW_STATUS_ACTIVE);
WebSphereUowTransactionManager ptm = new WebSphereUowTransactionManager(manager);
DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_NEVER);
try {
ptm.execute(definition, new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus status) {
return "result";
}
});
fail("Should have thrown IllegalTransactionStateException");
}
catch (IllegalTransactionStateException ex) {
// expected
}
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:WebSphereUowTransactionManagerTests.java
示例6: rollback
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
/**
* This implementation of rollback handles participating in existing
* transactions. Delegates to {@code doRollback} and
* {@code doSetRollbackOnly}.
* @see #doRollback
* @see #doSetRollbackOnly
*/
@Override
public final void rollback(TransactionStatus status) throws TransactionException {
if (status.isCompleted()) {
throw new IllegalTransactionStateException(
"Transaction is already completed - do not call commit or rollback more than once per transaction");
}
DefaultTransactionStatus defStatus = (DefaultTransactionStatus) status;
processRollback(defStatus);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:AbstractPlatformTransactionManager.java
示例7: commit
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
public void commit() {
if (rollbackCalled) {
throw new IllegalTransactionStateException("Cannot call commit after rollback. Start another transaction first!");
}
try {
/*final Object[] objects =*/ redisTemplate.exec();
commitCalled = true;
} catch (Exception e) {
throw new TransactionSystemException("Exception occurred committing back Redis transaction: " + e.getMessage());
}
}
开发者ID:grails,项目名称:gorm-redis,代码行数:12,代码来源:RedisTransaction.java
示例8: testFlushWithoutTransaction
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
@Test
public void testFlushWithoutTransaction() {
try {
new TransactionalAspectMethods().testFlushWithoutTransaction();
Assertions.failExceptionExpected();
} catch (final Throwable t) {
Assertions.assertThat(t).isInstanceOf(IllegalTransactionStateException.class);
}
}
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:10,代码来源:SimpleTestDaoTest.java
示例9: testFlushWithoutTransaction
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
@Test
public void testFlushWithoutTransaction() {
Assertions.assertThrows(IllegalTransactionStateException.class, new Executable() {
@Override
public void execute() throws Throwable {
new TransactionalAspectMethods().testFlushWithoutTransaction();
}
});
}
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:10,代码来源:SimpleTestDaoTest.java
示例10: testMandatoryFailsWhenInvokedWithoutTx
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
@Test(expected = IllegalTransactionStateException.class)
public void testMandatoryFailsWhenInvokedWithoutTx() {
txUtil.executeWith_MANDATORY(new Runnable() {
@Override
public void run() {
fail("Must never reach this point!");
}
});
}
开发者ID:victorrentea,项目名称:training,代码行数:10,代码来源:TransactionUtilTest.java
示例11: testMandatoryPropagation
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
/** */
public void testMandatoryPropagation() {
IgniteCache<Integer, String> c = grid().cache(CACHE_NAME);
try {
service.putWithMandatoryPropagation(c);
}
catch (IllegalTransactionStateException e) {
assertEquals("No existing transaction found for transaction marked with propagation 'mandatory'", e.getMessage());
}
assertEquals(0, c.size());
}
开发者ID:apache,项目名称:ignite,代码行数:14,代码来源:GridSpringTransactionManagerSelfTest.java
示例12: proceed
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
private Object proceed(ProceedingJoinPoint pjp, Retry retryAnnotation) throws Throwable {
int times = retryAnnotation.times();
Class<? extends Throwable>[] retryOn = retryAnnotation.on();
Assert.isTrue(times > 0, "@Retry{times} should be greater than 0!");
Assert.isTrue(retryOn.length > 0, "@Retry{on} should have at least one Throwable!");
if (retryAnnotation.failInTransaction() && TransactionSynchronizationManager.isActualTransactionActive()) {
throw new IllegalTransactionStateException(
"You shouldn't retry an operation from within an existing Transaction." +
"This is because we can't retry if the current Transaction was already rolled back!");
}
LOGGER.info("Proceed with {} retries on {}", times, Arrays.toString(retryOn));
return tryProceeding(pjp, times, retryOn);
}
开发者ID:vladmihalcea,项目名称:db-util,代码行数:14,代码来源:OptimisticConcurrencyControlAspect.java
示例13: testRetryFailsOnTransaction
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
@Test(expected = IllegalTransactionStateException.class)
public void testRetryFailsOnTransaction() {
try {
TransactionSynchronizationManager.setActualTransactionActive(true);
itemService.saveItem();
} finally {
TransactionSynchronizationManager.setActualTransactionActive(false);
}
}
开发者ID:vladmihalcea,项目名称:db-util,代码行数:10,代码来源:OptimisticConcurrencyControlAspectTest.java
示例14: commit
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
/**
* This implementation of commit handles participating in existing
* transactions and programmatic rollback requests.
* Delegates to {@code isRollbackOnly}, {@code doCommit}
* and {@code rollback}.
* @see org.springframework.transaction.TransactionStatus#isRollbackOnly()
* @see #doCommit
* @see #rollback
*/
public final void commit(TransactionStatus status) throws TransactionException {
if (status.isCompleted()) {
throw new IllegalTransactionStateException(
"Transaction is already completed - do not call commit or rollback more than once per transaction");
}
DefaultTransactionStatus defStatus = (DefaultTransactionStatus) status;
if (defStatus.isLocalRollbackOnly()) {
if (defStatus.isDebug()) {
logger.debug("Transactional code has requested rollback");
}
processRollback(defStatus);
return;
}
if (!shouldCommitOnGlobalRollbackOnly() && defStatus.isGlobalRollbackOnly()) {
if (defStatus.isDebug()) {
logger.debug("Global transaction is marked as rollback-only but transactional code requested commit");
}
processRollback(defStatus);
// Throw UnexpectedRollbackException only at outermost transaction boundary
// or if explicitly asked to.
if (status.isNewTransaction() || isFailEarlyOnGlobalRollbackOnly()) {
throw new UnexpectedRollbackException(
"Transaction rolled back because it has been marked as rollback-only");
}
return;
}
processCommit(defStatus);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:40,代码来源:AbstractPlatformTransactionManager.java
示例15: rollback
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
/**
* This implementation of rollback handles participating in existing
* transactions. Delegates to {@code doRollback} and
* {@code doSetRollbackOnly}.
* @see #doRollback
* @see #doSetRollbackOnly
*/
public final void rollback(TransactionStatus status) throws TransactionException {
if (status.isCompleted()) {
throw new IllegalTransactionStateException(
"Transaction is already completed - do not call commit or rollback more than once per transaction");
}
DefaultTransactionStatus defStatus = (DefaultTransactionStatus) status;
processRollback(defStatus);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:AbstractPlatformTransactionManager.java
示例16: testTxRollbackInnerTxRollbackPropagationMandatory
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
/**
* PROPAGATION_MANDATORY:强制性的事务,当前的事务上下文中不存在事务的话,会抛出 {@link IllegalTransactionStateException}
*/
@Test(expected = IllegalTransactionStateException.class)
public void testTxRollbackInnerTxRollbackPropagationMandatory() {
springTxTest.txRollbackInnerTxRollbackPropagationMandatory();
}
开发者ID:khotyn,项目名称:spring-tx-test,代码行数:8,代码来源:TestMain.java
示例17: testTxRollbackInnerTxRollbackPropagationNever2
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
/**
* PROPAGATION_NEVER:不允许当前事务上下文中存在事务,如果有,则抛出 {@link IllegalTransactionStateException}
*/
@Test(expected = IllegalTransactionStateException.class)
public void testTxRollbackInnerTxRollbackPropagationNever2() {
springTxTest.txRollbackInnerTxRollbackPropagationNever2();
}
开发者ID:khotyn,项目名称:spring-tx-test,代码行数:8,代码来源:TestMain.java
示例18: testRetryFailsOnTransaction
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
@Test(expected = IllegalTransactionStateException.class)
public void testRetryFailsOnTransaction() {
itemService.saveItem();
}
开发者ID:vladmihalcea,项目名称:vladmihalcea.wordpress.com,代码行数:5,代码来源:OptimisticLockingTest.java
示例19: doSetRollbackOnly
import org.springframework.transaction.IllegalTransactionStateException; //导入依赖的package包/类
/**
* Set the given transaction rollback-only. Only called on rollback
* if the current transaction participates in an existing one.
* <p>The default implementation throws an IllegalTransactionStateException,
* assuming that participating in existing transactions is generally not
* supported. Subclasses are of course encouraged to provide such support.
* @param status the status representation of the transaction
* @throws TransactionException in case of system errors
*/
protected void doSetRollbackOnly(DefaultTransactionStatus status) throws TransactionException {
throw new IllegalTransactionStateException(
"Participating in existing transactions is not supported - when 'isExistingTransaction' " +
"returns true, appropriate 'doSetRollbackOnly' behavior must be provided");
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:AbstractPlatformTransactionManager.java
注:本文中的org.springframework.transaction.IllegalTransactionStateException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论