org.springframework.transaction.TransactionUsageException Java Examples

The following examples show how to use org.springframework.transaction.TransactionUsageException. 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: AbstractTransactionStatus.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Roll back to the savepoint that is held for the transaction
 * and release the savepoint right afterwards.
 */
public void rollbackToHeldSavepoint() throws TransactionException {
	Object savepoint = getSavepoint();
	if (savepoint == null) {
		throw new TransactionUsageException(
				"Cannot roll back to savepoint - no savepoint associated with current transaction");
	}
	getSavepointManager().rollbackToSavepoint(savepoint);
	getSavepointManager().releaseSavepoint(savepoint);
	setSavepoint(null);
}
 
Example #2
Source File: AbstractTransactionStatus.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Release the savepoint that is held for the transaction.
 */
public void releaseHeldSavepoint() throws TransactionException {
	Object savepoint = getSavepoint();
	if (savepoint == null) {
		throw new TransactionUsageException(
				"Cannot release savepoint - no savepoint associated with current transaction");
	}
	getSavepointManager().releaseSavepoint(savepoint);
	setSavepoint(null);
}
 
Example #3
Source File: JdbcTransactionObjectSupport.java    From spring-analysis-note with MIT License 5 votes vote down vote up
protected ConnectionHolder getConnectionHolderForSavepoint() throws TransactionException {
	if (!isSavepointAllowed()) {
		throw new NestedTransactionNotSupportedException(
				"Transaction manager does not allow nested transactions");
	}
	if (!hasConnectionHolder()) {
		throw new TransactionUsageException(
				"Cannot create nested transaction when not exposing a JDBC transaction");
	}
	return getConnectionHolder();
}
 
Example #4
Source File: AbstractTransactionStatus.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Roll back to the savepoint that is held for the transaction
 * and release the savepoint right afterwards.
 */
public void rollbackToHeldSavepoint() throws TransactionException {
	Object savepoint = getSavepoint();
	if (savepoint == null) {
		throw new TransactionUsageException(
				"Cannot roll back to savepoint - no savepoint associated with current transaction");
	}
	getSavepointManager().rollbackToSavepoint(savepoint);
	getSavepointManager().releaseSavepoint(savepoint);
	setSavepoint(null);
}
 
Example #5
Source File: AbstractTransactionStatus.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Release the savepoint that is held for the transaction.
 */
public void releaseHeldSavepoint() throws TransactionException {
	Object savepoint = getSavepoint();
	if (savepoint == null) {
		throw new TransactionUsageException(
				"Cannot release savepoint - no savepoint associated with current transaction");
	}
	getSavepointManager().releaseSavepoint(savepoint);
	setSavepoint(null);
}
 
Example #6
Source File: JdbcTransactionObjectSupport.java    From java-technology-stack with MIT License 5 votes vote down vote up
protected ConnectionHolder getConnectionHolderForSavepoint() throws TransactionException {
	if (!isSavepointAllowed()) {
		throw new NestedTransactionNotSupportedException(
				"Transaction manager does not allow nested transactions");
	}
	if (!hasConnectionHolder()) {
		throw new TransactionUsageException(
				"Cannot create nested transaction when not exposing a JDBC transaction");
	}
	return getConnectionHolder();
}
 
Example #7
Source File: AppTests.java    From tutorial with MIT License 5 votes vote down vote up
/**
 * MANDATORY要求必须在一个已有的事务中执行,否则抛出异常;
 * 此测试中,调用insertMandatory方法(方法声明Propagation.MANDATORY)之前没有开启事务
 * 所以必定会抛出异常
 */
public void testMandatory() {
    boolean b = false;
    try {
        serv.insertMandatory(new PersonDto(20002, "乙"), false);
    }catch(TransactionUsageException e) {
        log.trace(e.getClass().getName());
        b = true;
    }
    Assert.assertTrue(b);
}
 
Example #8
Source File: AbstractTransactionStatus.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Roll back to the savepoint that is held for the transaction
 * and release the savepoint right afterwards.
 */
public void rollbackToHeldSavepoint() throws TransactionException {
	if (!hasSavepoint()) {
		throw new TransactionUsageException(
				"Cannot roll back to savepoint - no savepoint associated with current transaction");
	}
	getSavepointManager().rollbackToSavepoint(getSavepoint());
	getSavepointManager().releaseSavepoint(getSavepoint());
	setSavepoint(null);
}
 
Example #9
Source File: AbstractTransactionStatus.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Release the savepoint that is held for the transaction.
 */
public void releaseHeldSavepoint() throws TransactionException {
	if (!hasSavepoint()) {
		throw new TransactionUsageException(
				"Cannot release savepoint - no savepoint associated with current transaction");
	}
	getSavepointManager().releaseSavepoint(getSavepoint());
	setSavepoint(null);
}
 
Example #10
Source File: JdbcTransactionObjectSupport.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
protected ConnectionHolder getConnectionHolderForSavepoint() throws TransactionException {
	if (!isSavepointAllowed()) {
		throw new NestedTransactionNotSupportedException(
				"Transaction manager does not allow nested transactions");
	}
	if (!hasConnectionHolder()) {
		throw new TransactionUsageException(
				"Cannot create nested transaction when not exposing a JDBC transaction");
	}
	return getConnectionHolder();
}
 
Example #11
Source File: AbstractTransactionStatus.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Roll back to the savepoint that is held for the transaction
 * and release the savepoint right afterwards.
 */
public void rollbackToHeldSavepoint() throws TransactionException {
	if (!hasSavepoint()) {
		throw new TransactionUsageException(
				"Cannot roll back to savepoint - no savepoint associated with current transaction");
	}
	getSavepointManager().rollbackToSavepoint(getSavepoint());
	getSavepointManager().releaseSavepoint(getSavepoint());
	setSavepoint(null);
}
 
Example #12
Source File: AbstractTransactionStatus.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Release the savepoint that is held for the transaction.
 */
public void releaseHeldSavepoint() throws TransactionException {
	if (!hasSavepoint()) {
		throw new TransactionUsageException(
				"Cannot release savepoint - no savepoint associated with current transaction");
	}
	getSavepointManager().releaseSavepoint(getSavepoint());
	setSavepoint(null);
}
 
Example #13
Source File: JdbcTransactionObjectSupport.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
protected ConnectionHolder getConnectionHolderForSavepoint() throws TransactionException {
	if (!isSavepointAllowed()) {
		throw new NestedTransactionNotSupportedException(
				"Transaction manager does not allow nested transactions");
	}
	if (!hasConnectionHolder()) {
		throw new TransactionUsageException(
				"Cannot create nested transaction if not exposing a JDBC transaction");
	}
	return getConnectionHolder();
}
 
Example #14
Source File: JdbcTransactionObjectSupport.java    From effectivejava with Apache License 2.0 5 votes vote down vote up
protected ConnectionHolder getConnectionHolderForSavepoint() throws TransactionException {
	if (!isSavepointAllowed()) {
		throw new NestedTransactionNotSupportedException(
				"Transaction manager does not allow nested transactions");
	}
	if (!hasConnectionHolder()) {
		throw new TransactionUsageException(
				"Cannot create nested transaction if not exposing a JDBC transaction");
	}
	return getConnectionHolder();
}