Top Description Methods
org.springframework.transaction.support

public Interface CallbackPreferringPlatformTransactionManager

extends PlatformTransactionManager
Imports
org.springframework.lang.Nullable, org.springframework.transaction.PlatformTransactionManager, .TransactionDefinition, .TransactionException

Extension of the org.springframework.transaction.PlatformTransactionManager interface, exposing a method for executing a given callback within a transaction.

Implementors of this interface automatically express a preference for callbacks over programmatic getTransaction, commit and rollback calls. Calling code may check whether a given transaction manager implements this interface to choose to prepare a callback instead of explicit transaction demarcation control.

Spring's TransactionTemplate and org.springframework.transaction.interceptor.TransactionInterceptor detect and use this PlatformTransactionManager variant automatically.

Author
Juergen Hoeller
Since
2.0
See Also
TransactionTemplate, org.springframework.transaction.interceptor.TransactionInterceptor

Method Summary

Modifier and TypeMethod and Description
public <T> T

Returns:

a result object returned by the callback, or null if none
execute
(TransactionDefinition
the definition for the transaction to wrap the callback in
definition
,
TransactionCallback<T>
the callback object that specifies the transactional action
callback
)

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

Inherited from org.springframework.transaction.PlatformTransactionManager:
commitgetTransactionrollback

Method Detail

executeback to summary
public <T> T execute(TransactionDefinition definition, TransactionCallback<T> callback) throws TransactionException

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
definition:TransactionDefinition

the definition for the transaction to wrap the callback in

callback:TransactionCallback<T>

the callback object that specifies the transactional action

Returns:T

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

Annotations
@Nullable
Exceptions
TransactionException:
in case of initialization, rollback, or system errors
RuntimeException:
if thrown by the TransactionCallback