org.springframework.transaction
Interface TransactionDefinition

All Known Subinterfaces:
TransactionAttribute
All Known Implementing Classes:
DefaultTransactionAttribute, DefaultTransactionDefinition

public interface TransactionDefinition

Interface for classes that define transaction properties. Base interface for TransactionAttribute.

Note that isolation level, timeout and read-only settings will only get applied when starting a new transaction. As only PROPAGATION_REQUIRED and PROPAGATION_REQUIRES_NEW can actually cause that, it doesn't make sense to specify any of those settings else. Furthermore, not all transaction managers will support those features and thus throw respective exceptions when given non-default values.

Since:
08.05.2003
Author:
Juergen Hoeller
See Also:
DefaultTransactionDefinition, TransactionAttribute

Field Summary
static java.lang.String ISOLATION_CONSTANT_PREFIX
           
static int ISOLATION_DEFAULT
          Use the default isolation level of the underlying datastore.
static int ISOLATION_READ_COMMITTED
           
static int ISOLATION_READ_UNCOMMITTED
           
static int ISOLATION_REPEATABLE_READ
           
static int ISOLATION_SERIALIZABLE
           
static java.lang.String PROPAGATION_CONSTANT_PREFIX
           
static int PROPAGATION_MANDATORY
          Support a current transaction, throw an exception if none exists.
static int PROPAGATION_NEVER
          Execute non-transactionally, throw an exception if a transaction exists.
static int PROPAGATION_NOT_SUPPORTED
          Execute non-transactionally, suspending the current transaction if one exists.
static int PROPAGATION_REQUIRED
          Support a current transaction, create a new one if none exists.
static int PROPAGATION_REQUIRES_NEW
          Create a new transaction, suspending the current transaction if one exists.
static int PROPAGATION_SUPPORTS
          Support a current transaction, execute non-transactionally if none exists.
static int TIMEOUT_DEFAULT
          Use the default timeout of the underlying transaction system, respectively none if timeouts are not supported.
 
Method Summary
 int getIsolationLevel()
          Return the isolation level.
 int getPropagationBehavior()
          Return the propagation behavior.
 int getTimeout()
          Return the transaction timeout.
 boolean isReadOnly()
          Return whether to optimize as read-only transaction.
 

Field Detail

PROPAGATION_CONSTANT_PREFIX

public static final java.lang.String PROPAGATION_CONSTANT_PREFIX
See Also:
Constant Field Values

ISOLATION_CONSTANT_PREFIX

public static final java.lang.String ISOLATION_CONSTANT_PREFIX
See Also:
Constant Field Values

PROPAGATION_REQUIRED

public static final int PROPAGATION_REQUIRED
Support a current transaction, create a new one if none exists. Analogous to EJB transaction attribute of the same name.

This is typically the default setting of a transaction definition.

See Also:
Constant Field Values

PROPAGATION_SUPPORTS

public static final int PROPAGATION_SUPPORTS
Support a current transaction, execute non-transactionally if none exists. Analogous to EJB transaction attribute of the same name.

See Also:
Constant Field Values

PROPAGATION_MANDATORY

public static final int PROPAGATION_MANDATORY
Support a current transaction, throw an exception if none exists. Analogous to EJB transaction attribute of the same name.

See Also:
Constant Field Values

PROPAGATION_REQUIRES_NEW

public static final int PROPAGATION_REQUIRES_NEW
Create a new transaction, suspending the current transaction if one exists. Analogous to EJB transaction attribute of the same name.

See Also:
Constant Field Values

PROPAGATION_NOT_SUPPORTED

public static final int PROPAGATION_NOT_SUPPORTED
Execute non-transactionally, suspending the current transaction if one exists. Analogous to EJB transaction attribute of the same name.

See Also:
Constant Field Values

PROPAGATION_NEVER

public static final int PROPAGATION_NEVER
Execute non-transactionally, throw an exception if a transaction exists. Analogous to EJB transaction attribute of the same name.

See Also:
Constant Field Values

ISOLATION_DEFAULT

public static final int ISOLATION_DEFAULT
Use the default isolation level of the underlying datastore. All other levels correspond to the JDBC isolation levels.

See Also:
Connection, Constant Field Values

ISOLATION_READ_UNCOMMITTED

public static final int ISOLATION_READ_UNCOMMITTED
See Also:
Constant Field Values

ISOLATION_READ_COMMITTED

public static final int ISOLATION_READ_COMMITTED
See Also:
Constant Field Values

ISOLATION_REPEATABLE_READ

public static final int ISOLATION_REPEATABLE_READ
See Also:
Constant Field Values

ISOLATION_SERIALIZABLE

public static final int ISOLATION_SERIALIZABLE
See Also:
Constant Field Values

TIMEOUT_DEFAULT

public static final int TIMEOUT_DEFAULT
Use the default timeout of the underlying transaction system, respectively none if timeouts are not supported.

See Also:
Constant Field Values
Method Detail

getPropagationBehavior

public int getPropagationBehavior()
Return the propagation behavior. Must return one of the PROPAGATION constants.

See Also:
PROPAGATION_REQUIRED

getIsolationLevel

public int getIsolationLevel()
Return the isolation level. Must return one of the ISOLATION constants.

Only makes sense in combination with PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW.

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

See Also:
ISOLATION_DEFAULT

getTimeout

public int getTimeout()
Return the transaction timeout. Must return a number of seconds, or TIMEOUT_DEFAULT.

Only makes sense in combination with PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW.

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

See Also:
TIMEOUT_DEFAULT

isReadOnly

public boolean isReadOnly()
Return whether to optimize as read-only transaction. This just serves as hint for the actual transaction subsystem, it will not necessarily cause failure of write accesses.

Only makes sense in combination with PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW.

A transaction manager that cannot interpret the read-only hint will not throw an exception when given readOnly=true.



Copyright (C) 2003-2004 The Spring Framework Project.