Package org.springframework.transaction.support

# Class DelegatingTransactionDefinition

java.lang.Object
org.springframework.transaction.support.DelegatingTransactionDefinition

All Implemented Interfaces:
  `Serializable`, `TransactionDefinition`

Direct Known Subclasses:
  `DelegatingTransactionAttribute`

public abstract class DelegatingTransactionDefinition extends Object implements TransactionDefinition, Serializable
`TransactionDefinition` implementation that delegates all calls to a given target `TransactionDefinition` instance. Abstract because it is meant to be subclassed, with subclasses overriding specific methods that are not supposed to simply delegate to the target instance.

Since:
  3.0
Author:
  Juergen Hoeller
See Also:
  - Serialized Form

## Field Summary

### Fields inherited from interface org.springframework.transaction.TransactionDefinition

`ISOLATION_DEFAULT, ISOLATION_READ_COMMITTED, ISOLATION_READ_UNCOMMITTED, ISOLATION_REPEATABLE_READ, ISOLATION_SERIALIZABLE, PROPAGATION_MANDATORY, PROPAGATION_NESTED, PROPAGATION_NEVER, PROPAGATION_NOT_SUPPORTED, PROPAGATION_REQUIRED, PROPAGATION_REQUIRES_NEW, PROPAGATION_SUPPORTS, TIMEOUT_DEFAULT`

## Constructor Summary

Constructors
Constructor
Description
`DelegatingTransactionDefinition(TransactionDefinition targetDefinition)`
Create a DelegatingTransactionAttribute for the given target attribute.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object other)`
`int`
`getIsolationLevel()`
Return the isolation level.
`String`
`getName()`
Return the name of this transaction.
`int`
`getPropagationBehavior()`
Return the propagation behavior.
`int`
`getTimeout()`
Return the transaction timeout.
`int`
`hashCode()`
`boolean`
`isReadOnly()`
Return whether to optimize as a read-only transaction.
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### DelegatingTransactionDefinition

public DelegatingTransactionDefinition(TransactionDefinition targetDefinition)
Create a DelegatingTransactionAttribute for the given target attribute.

Parameters:
  `targetDefinition` - the target TransactionAttribute to delegate to

## Method Details

### getPropagationBehavior

public int getPropagationBehavior()
Description copied from interface: `TransactionDefinition`
Return the propagation behavior.

Must return one of the `PROPAGATION_XXX` constants defined on `this interface`.

The default is `TransactionDefinition.PROPAGATION_REQUIRED`.

Specified by:
  `getPropagationBehavior` in interface `TransactionDefinition`
Returns:
  the propagation behavior
See Also:
  - `TransactionDefinition.PROPAGATION_REQUIRED`
  - `TransactionSynchronizationManager.isActualTransactionActive()`

### getIsolationLevel

public int getIsolationLevel()
Description copied from interface: `TransactionDefinition`
Return the isolation level.

Must return one of the `ISOLATION_XXX` constants defined on `this interface`. Those constants are designed to match the values of the same constants on `Connection`.

Exclusively designed for use with `TransactionDefinition.PROPAGATION_REQUIRED` or `TransactionDefinition.PROPAGATION_REQUIRES_NEW` since it only applies to newly started transactions. Consider switching the "validateExistingTransactions" flag to "true" on your transaction manager if you'd like isolation level declarations to get rejected when participating in an existing transaction with a different isolation level.

The default is `TransactionDefinition.ISOLATION_DEFAULT`. Note that a transaction manager that does not support custom isolation levels will throw an exception when given any other level than `TransactionDefinition.ISOLATION_DEFAULT`.

Specified by:
  `getIsolationLevel` in interface `TransactionDefinition`
Returns:
  the isolation level
See Also:
  - `TransactionDefinition.ISOLATION_DEFAULT`
  - `AbstractPlatformTransactionManager.setValidateExistingTransaction(boolean)`

### getTimeout

public int getTimeout()
Description copied from interface: `TransactionDefinition`
Return the transaction timeout.

Must return a number of seconds, or `TransactionDefinition.TIMEOUT_DEFAULT`.

Exclusively designed for use with `TransactionDefinition.PROPAGATION_REQUIRED` or `TransactionDefinition.PROPAGATION_REQUIRES_NEW` since it only applies to newly started transactions.

Note that a transaction manager that does not support timeouts will throw an exception when given any other timeout than `TransactionDefinition.TIMEOUT_DEFAULT`.

The default is `TransactionDefinition.TIMEOUT_DEFAULT`.

Specified by:
  `getTimeout` in interface `TransactionDefinition`
Returns:
  the transaction timeout

### isReadOnly

public boolean isReadOnly()
Description copied from interface: `TransactionDefinition`
Return whether to optimize as a read-only transaction.

The read-only flag applies to any transaction context, whether backed by an actual resource transaction (`TransactionDefinition.PROPAGATION_REQUIRED`/ `TransactionDefinition.PROPAGATION_REQUIRES_NEW`) or operating non-transactionally at the resource level (`TransactionDefinition.PROPAGATION_SUPPORTS`). In the latter case, the flag will only apply to managed resources within the application, such as a Hibernate `Session`.

This just serves as a hint for the actual transaction subsystem; it will not necessarily cause failure of write access attempts. A transaction manager which cannot interpret the read-only hint will not throw an exception when asked for a read-only transaction.

Specified by:
  `isReadOnly` in interface `TransactionDefinition`
Returns:
  `true` if the transaction is to be optimized as read-only (`false` by default)
See Also:
  - `TransactionSynchronization.beforeCommit(boolean)`
  - `TransactionSynchronizationManager.isCurrentTransactionReadOnly()`

### getName

@Nullable public String getName()
Description copied from interface: `TransactionDefinition`
Return the name of this transaction. Can be `null`.

This will be used as the transaction name to be shown in a transaction monitor, if applicable.

In case of Spring's declarative transactions, the exposed name will be the `fully-qualified class name + "." + method name` (by default).

Specified by:
  `getName` in interface `TransactionDefinition`
Returns:
  the name of this transaction (`null` by default}
See Also:
  - `TransactionAspectSupport`
  - `TransactionSynchronizationManager.getCurrentTransactionName()`

### equals

public boolean equals(@Nullable Object other)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`