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 aConnectionHolder
with a JDBCConnection
, and implements theSavepointManager
interface based on thatConnectionHolder
.Allows for programmatic management of JDBC
Savepoints
. Spring'sDefaultTransactionStatus
automatically delegates to this, as it autodetects transaction objects which implement theSavepointManager
interface.- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
DataSourceTransactionManager
Constructor Summary
Constructors Constructor Description JdbcTransactionObjectSupport()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
createSavepoint()
This implementation creates a JDBC 3.0 Savepoint and returns it.void
flush()
Flush the underlying sessions to the datastore, if applicable: for example, all affected Hibernate/JPA sessions.ConnectionHolder
getConnectionHolder()
protected ConnectionHolder
getConnectionHolderForSavepoint()
Integer
getPreviousIsolationLevel()
boolean
hasConnectionHolder()
boolean
isSavepointAllowed()
void
releaseSavepoint(Object savepoint)
This implementation releases the given JDBC 3.0 Savepoint.void
rollbackToSavepoint(Object savepoint)
This implementation rolls back to the given JDBC 3.0 Savepoint.void
setConnectionHolder(ConnectionHolder connectionHolder)
void
setPreviousIsolationLevel(Integer previousIsolationLevel)
void
setSavepointAllowed(boolean savepointAllowed)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.transaction.support.SmartTransactionObject
isRollbackOnly
Constructor Detail
JdbcTransactionObjectSupport
public JdbcTransactionObjectSupport()
Method Detail
setConnectionHolder
public void setConnectionHolder(ConnectionHolder connectionHolder)
getConnectionHolder
public ConnectionHolder getConnectionHolder()
hasConnectionHolder
public boolean hasConnectionHolder()
setPreviousIsolationLevel
public void setPreviousIsolationLevel(Integer previousIsolationLevel)
getPreviousIsolationLevel
public Integer getPreviousIsolationLevel()
setSavepointAllowed
public void setSavepointAllowed(boolean savepointAllowed)
isSavepointAllowed
public boolean isSavepointAllowed()
flush
public void flush()
Description copied from interface:SmartTransactionObject
Flush the underlying sessions to the datastore, if applicable: for example, all affected Hibernate/JPA sessions.- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in interfaceSmartTransactionObject
createSavepoint
public Object createSavepoint() throws TransactionException
This implementation creates a JDBC 3.0 Savepoint and returns it.- Specified by:
createSavepoint
in 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:
Connection.setSavepoint()
rollbackToSavepoint
public void rollbackToSavepoint(Object savepoint) throws TransactionException
This implementation rolls back to the given JDBC 3.0 Savepoint.- Specified by:
rollbackToSavepoint
in 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:
Connection.rollback(java.sql.Savepoint)
releaseSavepoint
public void releaseSavepoint(Object savepoint) throws TransactionException
This implementation releases the given JDBC 3.0 Savepoint.- Specified by:
releaseSavepoint
in interfaceSavepointManager
- Parameters:
savepoint
- the savepoint to release- Throws:
NestedTransactionNotSupportedException
- if the underlying transaction does not support savepointsTransactionException
- if the release failed- See Also:
Connection.releaseSavepoint(java.sql.Savepoint)
getConnectionHolderForSavepoint
protected ConnectionHolder getConnectionHolderForSavepoint() throws TransactionException
- Throws:
TransactionException