Top Description Fields Constructors Methods
org.springframework.transaction.support

pack-priv final Class WithoutTransactionOperations

extends Object
implements TransactionOperations
Class Inheritance
All Implemented Interfaces
org.springframework.transaction.support.TransactionOperations
Imports
java.util.function.Consumer, org.springframework.lang.Nullable, org.springframework.transaction.TransactionException, .TransactionStatus

A TransactionOperations implementation which executes a given TransactionCallback without an actual transaction.
Author
Juergen Hoeller
Since
5.2
See Also
TransactionOperations#withoutTransaction()

Field Summary

Modifier and TypeField and Description
pack-priv static final WithoutTransactionOperations

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public <T> T
execute(TransactionCallback<T>
the callback object that specifies the transactional action
action
)

Implements org.springframework.transaction.support.TransactionOperations.execute.

Execute the action specified by the given callback object within a transaction.

public void
executeWithoutResult(Consumer<TransactionStatus>
the Runnable that specifies the transactional action
action
)

Overrides default org.springframework.transaction.support.TransactionOperations.executeWithoutResult.

Execute the action specified by the given Runnable within a transaction.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
pack-priv static final WithoutTransactionOperations INSTANCE

Constructor Detail

WithoutTransactionOperationsback to summary
private WithoutTransactionOperations()

Method Detail

executeback to summary
public <T> T execute(TransactionCallback<T> action) throws TransactionException

Implements org.springframework.transaction.support.TransactionOperations.execute.

Doc from org.springframework.transaction.support.TransactionOperations.execute.

Execute the action specified by the given callback object within a transaction.

Allows for returning a result object created within the transaction, that is, a domain object or a collection of domain objects. A RuntimeException thrown by the callback is treated as a fatal exception that enforces a rollback. Such an exception gets propagated to the caller of the template.

Parameters
action:TransactionCallback<T>

the callback object that specifies the transactional action

Returns:T

a result object returned by the callback, or null if none

Annotations
@Override
@Nullable
Exceptions
TransactionException:
in case of initialization, rollback, or system errors
executeWithoutResultback to summary
public void executeWithoutResult(Consumer<TransactionStatus> action) throws TransactionException

Overrides default org.springframework.transaction.support.TransactionOperations.executeWithoutResult.

Doc from org.springframework.transaction.support.TransactionOperations.executeWithoutResult.

Execute the action specified by the given Runnable within a transaction.

If you need to return an object from the callback or access the org.springframework.transaction.TransactionStatus from within the callback, use execute(TransactionCallback) instead.

This variant is analogous to using a TransactionCallbackWithoutResult but with a simplified signature for common cases - and conveniently usable with Java 8 lambda expressions.

Parameters
action:Consumer<TransactionStatus>

the Runnable that specifies the transactional action

Annotations
@Override
Exceptions
TransactionException:
in case of initialization, rollback, or system errors