org.springframework.jdbc.datasource
Class JdbcTransactionObjectSupport

java.lang.Object
  extended byorg.springframework.jdbc.datasource.JdbcTransactionObjectSupport
All Implemented Interfaces:
SavepointManager, SmartTransactionObject

public abstract class JdbcTransactionObjectSupport
extends Object
implements SavepointManager, SmartTransactionObject

Convenient base class for JDBC-aware transaction objects. Can contain a ConnectionHolder, and implements the SavepointManager interface based on that ConnectionHolder.

Implements the SavepointManager interface to allow for programmatic management of JDBC 3.0 Savepoints. DefaultTransactionStatus will automatically delegate to this, as it auto-detects transaction objects that implement the SavepointManager interface.

Note that savepoints are only supported for JDBC 3.0.

Since:
1.1
Author:
Juergen Hoeller
See Also:
Savepoint

Field Summary
protected static Log logger
           
 
Constructor Summary
JdbcTransactionObjectSupport()
           
 
Method Summary
 Object createSavepoint()
          This implementation creates a JDBC 3.0 Savepoint and returns it.
 ConnectionHolder getConnectionHolder()
           
protected  ConnectionHolder getConnectionHolderForSavepoint()
           
 Integer getPreviousIsolationLevel()
           
 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
 

Field Detail

logger

protected static final Log logger
Constructor Detail

JdbcTransactionObjectSupport

public JdbcTransactionObjectSupport()
Method Detail

setConnectionHolder

public void setConnectionHolder(ConnectionHolder connectionHolder)

getConnectionHolder

public ConnectionHolder getConnectionHolder()

setPreviousIsolationLevel

public void setPreviousIsolationLevel(Integer previousIsolationLevel)

getPreviousIsolationLevel

public Integer getPreviousIsolationLevel()

setSavepointAllowed

public void setSavepointAllowed(boolean savepointAllowed)

isSavepointAllowed

public boolean isSavepointAllowed()

createSavepoint

public Object createSavepoint()
                       throws TransactionException
This implementation creates a JDBC 3.0 Savepoint and returns it.

Specified by:
createSavepoint in interface SavepointManager
Returns:
a savepoint object, to be passed into rollbackToSavepoint or releaseSavepoint
Throws:
TransactionException - if the savepoint could not be created, either because the backend does not support it or 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 interface SavepointManager
Parameters:
savepoint - the savepoint to roll back to
Throws:
TransactionException - 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 interface SavepointManager
Parameters:
savepoint - the savepoint to release
Throws:
TransactionException - if the release failed
See Also:
Connection.releaseSavepoint(java.sql.Savepoint)

getConnectionHolderForSavepoint

protected ConnectionHolder getConnectionHolderForSavepoint()
                                                    throws TransactionException
Throws:
TransactionException


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