JdbcAccessor-aligned subclass of the plain DataSourceTransactionManager,
adding common JDBC exception translation for the commit and rollback step.
Typically used in combination with org.springframework.jdbc.core.JdbcTemplate
which applies the same SQLExceptionTranslator infrastructure by default.
Exception translation is specifically relevant for commit steps in serializable
transactions (e.g. on Postgres) where concurrency failures may occur late on commit.
This allows for throwing org. to
callers instead of org..
Analogous to HibernateTransactionManager and JpaTransactionManager,
this transaction manager may throw DataAccessException from commit
and possibly also from rollback. Calling code should be prepared for handling
such exceptions next to org.,
which is generally sensible since TransactionSynchronization implementations
may also throw such exceptions in their flush and beforeCommit phases.
DataSourceTransactionManager, setDataSource, setExceptionTranslator
| Modifier and Type | Field and Description |
|---|---|
| private volatile SQLExceptionTranslator | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | JdbcTransactionManager(DataSource
the JDBC DataSource to manage transactions for dataSource)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Overrides org. Implements org. Eagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set. |
| public SQLExceptionTranslator | getExceptionTranslator()
Return the exception translator to use for this instance, creating a default if necessary. |
| public boolean | isLazyInit()
Return whether to lazily initialize the SQLExceptionTranslator for this transaction manager. |
| public void | setDatabaseProductName(String
the database product name that identifies the error codes entry dbName)Specify the database product name for the |
| public void | setExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
Set the exception translator for this transaction manager. |
| public void | setLazyInit(boolean lazyInit)
Set whether to lazily initialize the SQLExceptionTranslator for this transaction manager, on first encounter of an SQLException. |
| protected RuntimeException | translateException(String
the task description (commit or rollback) task, SQLException the SQLException thrown from commit/rollback ex)Overrides org. This implementation attempts to use the |
| exceptionTranslator | back to summary |
|---|---|
| private volatile SQLExceptionTranslator exceptionTranslator
| |
| lazyInit | back to summary |
|---|---|
| private boolean lazyInit | |
| JdbcTransactionManager | back to summary |
|---|---|
| public JdbcTransactionManager() Create a new
| |
| JdbcTransactionManager | back to summary |
|---|---|
| public JdbcTransactionManager(DataSource dataSource) Create a new
| |
| afterPropertiesSet | back to summary |
|---|---|
| public void afterPropertiesSet() Overrides org. Implements org. Eagerly initialize the exception translator, if demanded, creating a default one for the specified DataSource if none set.
| |
| getExceptionTranslator | back to summary |
|---|---|
| public SQLExceptionTranslator getExceptionTranslator() Return the exception translator to use for this instance, creating a default if necessary.
| |
| isLazyInit | back to summary |
|---|---|
| public boolean isLazyInit() Return whether to lazily initialize the SQLExceptionTranslator for this transaction manager.
| |
| setDatabaseProductName | back to summary |
|---|---|
| public void setDatabaseProductName(String dbName) Specify the database product name for the
| |
| setExceptionTranslator | back to summary |
|---|---|
| public void setExceptionTranslator(SQLExceptionTranslator exceptionTranslator) Set the exception translator for this transaction manager. A | |
| setLazyInit | back to summary |
|---|---|
| public void setLazyInit(boolean lazyInit) Set whether to lazily initialize the SQLExceptionTranslator for this transaction manager, on first encounter of an SQLException. Default is "true"; can be switched to "false" for initialization on startup. Early initialization just applies if
| |