Class JdbcTransactionObjectSupport
java.lang.Object
org.springframework.jdbc.datasource.JdbcTransactionObjectSupport
- All Implemented Interfaces:
Flushable,SavepointManager,SmartTransactionObject
public abstract class JdbcTransactionObjectSupport
extends Object
implements SavepointManager, SmartTransactionObject
Convenient base class for JDBC-aware transaction objects. Can contain a
ConnectionHolder with a JDBC Connection, and implements the
SavepointManager interface based on that ConnectionHolder.
Allows for programmatic management of JDBC Savepoints.
Spring's DefaultTransactionStatus
automatically delegates to this, as it autodetects transaction objects which
implement the SavepointManager interface.
- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThis implementation creates a JDBC 3.0 Savepoint and returns it.voidflush()Flush the underlying sessions to the datastore, if applicable: for example, all affected Hibernate/JPA sessions.Return the ConnectionHolder for this transaction object.protected ConnectionHolderReturn the retained previous isolation level, if any.booleanCheck whether this transaction object has a ConnectionHolder.booleanReturn the read-only status of this transaction.booleanReturn whether savepoints are allowed within this transaction.voidreleaseSavepoint(Object savepoint) This implementation releases the given JDBC 3.0 Savepoint.voidrollbackToSavepoint(Object savepoint) This implementation rolls back to the given JDBC 3.0 Savepoint.voidsetConnectionHolder(ConnectionHolder connectionHolder) Set the ConnectionHolder for this transaction object.voidsetPreviousIsolationLevel(Integer previousIsolationLevel) Set the previous isolation level to retain, if any.voidsetReadOnly(boolean readOnly) Set the read-only status of this transaction.voidsetSavepointAllowed(boolean savepointAllowed) Set whether savepoints are allowed within this transaction.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.transaction.support.SmartTransactionObject
isRollbackOnly
-
Constructor Details
-
JdbcTransactionObjectSupport
public JdbcTransactionObjectSupport()
-
-
Method Details
-
setConnectionHolder
Set the ConnectionHolder for this transaction object. -
getConnectionHolder
Return the ConnectionHolder for this transaction object. -
hasConnectionHolder
public boolean hasConnectionHolder()Check whether this transaction object has a ConnectionHolder. -
setPreviousIsolationLevel
Set the previous isolation level to retain, if any. -
getPreviousIsolationLevel
Return the retained previous isolation level, if any. -
setReadOnly
public void setReadOnly(boolean readOnly) Set the read-only status of this transaction. The default isfalse.- Since:
- 5.2.1
-
isReadOnly
public boolean isReadOnly()Return the read-only status of this transaction.- Since:
- 5.2.1
-
setSavepointAllowed
public void setSavepointAllowed(boolean savepointAllowed) Set whether savepoints are allowed within this transaction. The default isfalse. -
isSavepointAllowed
public boolean isSavepointAllowed()Return whether savepoints are allowed within this transaction. -
flush
public void flush()Description copied from interface:SmartTransactionObjectFlush the underlying sessions to the datastore, if applicable: for example, all affected Hibernate/JPA sessions.- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceSmartTransactionObject
-
createSavepoint
This implementation creates a JDBC 3.0 Savepoint and returns it.- Specified by:
createSavepointin interfaceSavepointManager- Returns:
- a savepoint object, to be passed into
SavepointManager.rollbackToSavepoint(java.lang.Object)orSavepointManager.releaseSavepoint(java.lang.Object) - Throws:
NestedTransactionNotSupportedException- if the underlying transaction does not support savepointsTransactionException- if the savepoint could not be created, for example because the transaction is not in an appropriate state- See Also:
-
rollbackToSavepoint
This implementation rolls back to the given JDBC 3.0 Savepoint.- Specified by:
rollbackToSavepointin interfaceSavepointManager- Parameters:
savepoint- the savepoint to roll back to- Throws:
NestedTransactionNotSupportedException- if the underlying transaction does not support savepointsTransactionException- if the rollback failed- See Also:
-
releaseSavepoint
This implementation releases the given JDBC 3.0 Savepoint.- Specified by:
releaseSavepointin interfaceSavepointManager- Parameters:
savepoint- the savepoint to release- Throws:
NestedTransactionNotSupportedException- if the underlying transaction does not support savepointsTransactionException- if the release failed- See Also:
-
getConnectionHolderForSavepoint
- Throws:
TransactionException
-