Package org.springframework.jdbc.datasource

# Class JdbcTransactionObjectSupport

java.lang.Object
org.springframework.jdbc.datasource.JdbcTransactionObjectSupport

All Implemented Interfaces:
  `Flushable`, `org.springframework.transaction.SavepointManager`, `org.springframework.transaction.support.SmartTransactionObject`

public abstract class JdbcTransactionObjectSupport extends Object implements org.springframework.transaction.SavepointManager, org.springframework.transaction.support.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:
  - `DataSourceTransactionManager`

## Constructor Summary

Constructors
Constructor
Description
`JdbcTransactionObjectSupport()`

## Method Summary

Modifier and Type
Method
Description
`Object`
`createSavepoint()`
This implementation creates a JDBC Savepoint and returns it.
`ConnectionHolder`
`getConnectionHolder()`
Return the ConnectionHolder for this transaction object.
`protected ConnectionHolder`
`getConnectionHolderForSavepoint()`
`Integer`
`getPreviousIsolationLevel()`
Return the retained previous isolation level, if any.
`boolean`
`hasConnectionHolder()`
Check whether this transaction object has a ConnectionHolder.
`boolean`
`isReadOnly()`
Return the read-only status of this transaction.
`boolean`
`isSavepointAllowed()`
Return whether savepoints are allowed within this transaction.
`void`
`releaseSavepoint(Object savepoint)`
This implementation releases the given JDBC Savepoint.
`void`
`rollbackToSavepoint(Object savepoint)`
This implementation rolls back to the given JDBC Savepoint.
`void`
`setConnectionHolder(ConnectionHolder connectionHolder)`
Set the ConnectionHolder for this transaction object.
`void`
`setPreviousIsolationLevel(Integer previousIsolationLevel)`
Set the previous isolation level to retain, if any.
`void`
`setReadOnly(boolean readOnly)`
Set the read-only status of this transaction.
`void`
`setSavepointAllowed(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, wait`

### Methods inherited from interface org.springframework.transaction.support.SmartTransactionObject

`flush, isRollbackOnly`

## Constructor Details

### JdbcTransactionObjectSupport

public JdbcTransactionObjectSupport()

## Method Details

### setConnectionHolder

public void setConnectionHolder(@Nullable ConnectionHolder connectionHolder)
Set the ConnectionHolder for this transaction object.

### getConnectionHolder

public ConnectionHolder getConnectionHolder()
Return the ConnectionHolder for this transaction object.

### hasConnectionHolder

public boolean hasConnectionHolder()
Check whether this transaction object has a ConnectionHolder.

### setPreviousIsolationLevel

public void setPreviousIsolationLevel(@Nullable Integer previousIsolationLevel)
Set the previous isolation level to retain, if any.

### getPreviousIsolationLevel

@Nullable public Integer 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 is `false`.

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 is `false`.

### isSavepointAllowed

public boolean isSavepointAllowed()
Return whether savepoints are allowed within this transaction.

### createSavepoint

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

Specified by:
  `createSavepoint` in interface `org.springframework.transaction.SavepointManager`
Throws:
  `org.springframework.transaction.TransactionException`
See Also:
  - `Connection.setSavepoint()`

### rollbackToSavepoint

public void rollbackToSavepoint(Object savepoint) throws org.springframework.transaction.TransactionException
This implementation rolls back to the given JDBC Savepoint.

Specified by:
  `rollbackToSavepoint` in interface `org.springframework.transaction.SavepointManager`
Throws:
  `org.springframework.transaction.TransactionException`
See Also:
  - `Connection.rollback(java.sql.Savepoint)`

### releaseSavepoint

public void releaseSavepoint(Object savepoint) throws org.springframework.transaction.TransactionException
This implementation releases the given JDBC Savepoint.

Specified by:
  `releaseSavepoint` in interface `org.springframework.transaction.SavepointManager`
Throws:
  `org.springframework.transaction.TransactionException`
See Also:
  - `Connection.releaseSavepoint(java.sql.Savepoint)`

### getConnectionHolderForSavepoint

protected ConnectionHolder getConnectionHolderForSavepoint() throws org.springframework.transaction.TransactionException

Throws:
  `org.springframework.transaction.TransactionException`