java.lang.Object | |
↳ | org.springframework.orm.jdo.DefaultJdoDialect |
Default implementation of the JdoDialect
interface.
Updated to build on JDO 2.0 or higher, as of Spring 2.5.
Used as default dialect by JdoAccessor
and JdoTransactionManager
.
Simply begins a standard JDO transaction in beginTransaction
.
Returns a handle for a JDO2 DataStoreConnection on getJdbcConnection
.
Calls the corresponding JDO2 PersistenceManager operation on flush
Ignores a given query timeout in applyQueryTimeout
.
Uses a Spring SQLExceptionTranslator for exception translation, if applicable.
Note that, even with JDO2, vendor-specific subclasses are still necessary
for special transaction semantics and more sophisticated exception translation.
Furthermore, vendor-specific subclasses are encouraged to expose the native JDBC
Connection on getJdbcConnection
, rather than JDO2's wrapper handle.
This class also implements the PersistenceExceptionTranslator interface, as autodetected by Spring's PersistenceExceptionTranslationPostProcessor, for AOP-based translation of native exceptions to Spring DataAccessExceptions. Hence, the presence of a standard DefaultJdoDialect bean automatically enables a PersistenceExceptionTranslationPostProcessor to translate JDO exceptions.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
logger |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new DefaultJdoDialect.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This implementation applies a JDO 3.0 query timeout, if available.
| |||||||||||
This implementation invokes the standard JDO
Transaction.begin
method. | |||||||||||
This implementation does nothing, as the default beginTransaction implementation
does not require any cleanup.
| |||||||||||
This implementation returns a DataStoreConnectionHandle for JDO2,
which will also work on JDO1 until actually accessing the JDBC Connection.
| |||||||||||
Return the JDBC exception translator for this dialect, if any.
| |||||||||||
This implementation does nothing, assuming that the Connection
will implicitly be closed with the PersistenceManager.
| |||||||||||
Set the JDBC exception translator for this dialect.
| |||||||||||
This implementation delegates to PersistenceManagerFactoryUtils.
| |||||||||||
Implementation of the PersistenceExceptionTranslator interface,
as autodetected by Spring's PersistenceExceptionTranslationPostProcessor.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Template method for extracting a SQL String from the given exception.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.dao.support.PersistenceExceptionTranslator
| |||||||||||
From interface
org.springframework.orm.jdo.JdoDialect
|
Create a new DefaultJdoDialect.
This implementation applies a JDO 3.0 query timeout, if available. Otherwise, it sets the JPA 2.0 query hints "javax.persistence.lock.timeout" and "javax.persistence.query.timeout", assuming that JDO providers are often JPA providers as well.
query | the JDO query object to apply the timeout to |
---|---|
remainingTimeInSeconds | the timeout value (seconds) to apply |
JDOException |
---|
This implementation invokes the standard JDO Transaction.begin
method. Throws an InvalidIsolationLevelException if a non-default isolation
level is set.
transaction | the JDO transaction to begin |
---|---|
definition | the Spring transaction definition that defines semantics |
JDOException | |
---|---|
SQLException | |
TransactionException |
InvalidIsolationLevelException
This implementation does nothing, as the default beginTransaction implementation does not require any cleanup.
transactionData | arbitrary object that holds transaction data, if any (as returned by beginTransaction) |
---|
This implementation returns a DataStoreConnectionHandle for JDO2, which will also work on JDO1 until actually accessing the JDBC Connection.
For pre-JDO2 implementations, override this method to return the
Connection through the corresponding vendor-specific mechanism, or null
if the Connection is not retrievable.
NOTE: A JDO2 DataStoreConnection is always a wrapper, never the native JDBC Connection. If you need access to the native JDBC Connection (or the connection pool handle, to be unwrapped via a Spring NativeJdbcExtractor), override this method to return the native Connection through the corresponding vendor-specific mechanism.
A JDO2 DataStoreConnection is only "borrowed" from the PersistenceManager:
it needs to be returned as early as possible. Effectively, JDO2 requires the
fetched Connection to be closed before continuing PersistenceManager work.
For this reason, the exposed ConnectionHandle eagerly releases its JDBC
Connection at the end of each JDBC data access operation (that is, on
DataSourceUtils.releaseConnection
).
pm | the current JDO PersistenceManager |
---|---|
readOnly | whether the Connection is only needed for read-only purposes |
releaseJdbcConnection
, or null
if no JDBC Connection can be retrievedJDOException | |
---|---|
SQLException |
NativeJdbcExtractor
releaseConnection(Connection, DataSource)
Return the JDBC exception translator for this dialect, if any.
This implementation does nothing, assuming that the Connection will implicitly be closed with the PersistenceManager.
If the JDO provider returns a Connection handle that it
expects the application to close, the dialect needs to invoke
Connection.close
here.
conHandle | the JDBC Connection handle to release |
---|---|
pm | the current JDO PersistenceManager |
JDOException | |
---|---|
SQLException |
Set the JDBC exception translator for this dialect.
Applied to any SQLException root cause of a JDOException, if specified. The default is to rely on the JDO provider's native exception translation.
jdbcExceptionTranslator | exception translator |
---|
SQLException
SQLErrorCodeSQLExceptionTranslator
SQLStateSQLExceptionTranslator
This implementation delegates to PersistenceManagerFactoryUtils.
ex | the JDOException thrown |
---|
null
)Implementation of the PersistenceExceptionTranslator interface, as autodetected by Spring's PersistenceExceptionTranslationPostProcessor.
Converts the exception if it is a JDOException, using this JdoDialect.
Else returns null
to indicate an unknown exception.
ex | a RuntimeException thrown |
---|
null
if the
exception could not be translated, as in this case it may result from
user code rather than an actual persistence problem)Template method for extracting a SQL String from the given exception.
Default implementation always returns null
. Can be overridden in
subclasses to extract SQL Strings for vendor-specific exception classes.
ex | the JDOException, containing a SQLException |
---|
null
if none found