| java.lang.Object org.springframework.orm.jdo.DefaultJdoDialect
DefaultJdoDialect | public class DefaultJdoDialect implements JdoDialect,PersistenceExceptionTranslator(Code) | | Default implementation of the JdoDialect interface.
Updated to leverage the JDO 2.0 API when available, as of Spring 1.2.
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 operations on detachCopy(All) ,
attachCopy(All) , flush and newNamedQuery .
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.
author: Juergen Hoeller since: 1.1 See Also: DefaultJdoDialect.setJdbcExceptionTranslator See Also: JdoAccessor.setJdoDialect See Also: JdoTransactionManager.setJdoDialect See Also: org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor |
Field Summary | |
final protected Log | logger |
Method Summary | |
public void | applyQueryTimeout(Query query, int remainingTimeInSeconds) This implementation logs a warning that it cannot apply a query timeout. | public Object | attachCopy(PersistenceManager pm, Object detachedEntity) This implementation delegates to JDO 2.0's makePersistent method,
which also serves as facility for reattaching objects as of JDO 2.0 final draft.
To be overridden for pre-JDO2 implementations, using the corresponding
vendor-specific mechanism there.
Note that previous JDO 2.0 drafts specified a dedicated attachCopy
method for this purpose, which Spring's DefaultJdoDialect used to delegate to.
As of Spring 2.0, this has been adapted to the final JDO 2.0 API. | public Collection | attachCopyAll(PersistenceManager pm, Collection detachedEntities) This implementation delegates to JDO 2.0's makePersistentAll method,
which also serves as facility for reattaching objects as of JDO 2.0 final draft.
To be overridden for pre-JDO2 implementations, using the corresponding
vendor-specific mechanism there.
Note that previous JDO 2.0 drafts specified a dedicated attachCopy
method for this purpose, which Spring's DefaultJdoDialect used to delegate to.
As of Spring 2.0, this has been adapted to the final JDO 2.0 API. | public Object | beginTransaction(Transaction transaction, TransactionDefinition definition) This implementation invokes the standard JDO Transaction.begin
method. | public void | cleanupTransaction(Object transactionData) This implementation does nothing, as the default beginTransaction implementation
does not require any cleanup. | public Object | detachCopy(PersistenceManager pm, Object entity) This implementation delegates to JDO 2.0's detachCopy method. | public Collection | detachCopyAll(PersistenceManager pm, Collection entities) This implementation delegates to JDO 2.0's detachCopyAll method. | protected String | extractSqlStringFromException(JDOException ex) Template method for extracting a SQL String from the given exception.
Default implementation always returns null . | public void | flush(PersistenceManager pm) This implementation delegates to JDO 2.0's flush method. | public ConnectionHandle | getJdbcConnection(PersistenceManager pm, boolean readOnly) 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. | public SQLExceptionTranslator | getJdbcExceptionTranslator() Return the JDBC exception translator for this dialect, if any. | public Query | newNamedQuery(PersistenceManager pm, Class entityClass, String queryName) This implementation delegates to JDO 2.0's newNamedQuery method. | public void | releaseJdbcConnection(ConnectionHandle conHandle, PersistenceManager pm) This implementation does nothing, assuming that the Connection
will implicitly be closed with the PersistenceManager. | public void | setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator) Set the JDBC exception translator for this dialect. | public DataAccessException | translateException(JDOException ex) This implementation delegates to PersistenceManagerFactoryUtils. | public DataAccessException | translateExceptionIfPossible(RuntimeException ex) Implementation of the PersistenceExceptionTranslator interface,
as autodetected by Spring's PersistenceExceptionTranslationPostProcessor. |
logger | final protected Log logger(Code) | | |
DefaultJdoDialect | public DefaultJdoDialect()(Code) | | Create a new DefaultJdoDialect.
|
DefaultJdoDialect | DefaultJdoDialect(Object connectionFactory)(Code) | | Create a new DefaultJdoDialect.
Parameters: connectionFactory - the connection factory of the JDO PersistenceManagerFactory,which is used to initialize the default JDBC exception translator See Also: javax.jdo.PersistenceManagerFactory.getConnectionFactory See Also: PersistenceManagerFactoryUtils.newJdbcExceptionTranslator(Object) |
applyQueryTimeout | public void applyQueryTimeout(Query query, int remainingTimeInSeconds) throws JDOException(Code) | | This implementation logs a warning that it cannot apply a query timeout.
|
attachCopy | public Object attachCopy(PersistenceManager pm, Object detachedEntity) throws JDOException(Code) | | This implementation delegates to JDO 2.0's makePersistent method,
which also serves as facility for reattaching objects as of JDO 2.0 final draft.
To be overridden for pre-JDO2 implementations, using the corresponding
vendor-specific mechanism there.
Note that previous JDO 2.0 drafts specified a dedicated attachCopy
method for this purpose, which Spring's DefaultJdoDialect used to delegate to.
As of Spring 2.0, this has been adapted to the final JDO 2.0 API. You can still
create a custom JdoDialect that uses the pre-final API methods, of course.
See Also: javax.jdo.PersistenceManager.makePersistent(Object) |
attachCopyAll | public Collection attachCopyAll(PersistenceManager pm, Collection detachedEntities) throws JDOException(Code) | | This implementation delegates to JDO 2.0's makePersistentAll method,
which also serves as facility for reattaching objects as of JDO 2.0 final draft.
To be overridden for pre-JDO2 implementations, using the corresponding
vendor-specific mechanism there.
Note that previous JDO 2.0 drafts specified a dedicated attachCopy
method for this purpose, which Spring's DefaultJdoDialect used to delegate to.
As of Spring 2.0, this has been adapted to the final JDO 2.0 API. You can still
create a custom JdoDialect that uses the pre-final API methods, of course.
See Also: javax.jdo.PersistenceManager.makePersistentAll(java.util.Collection) |
cleanupTransaction | public void cleanupTransaction(Object transactionData)(Code) | | This implementation does nothing, as the default beginTransaction implementation
does not require any cleanup.
See Also: DefaultJdoDialect.beginTransaction |
detachCopy | public Object detachCopy(PersistenceManager pm, Object entity) throws JDOException(Code) | | This implementation delegates to JDO 2.0's detachCopy method.
To be overridden for pre-JDO2 implementations, using the corresponding
vendor-specific mechanism there.
See Also: javax.jdo.PersistenceManager.detachCopy(Object) |
detachCopyAll | public Collection detachCopyAll(PersistenceManager pm, Collection entities) throws JDOException(Code) | | This implementation delegates to JDO 2.0's detachCopyAll method.
To be overridden for pre-JDO2 implementations, using the corresponding
vendor-specific mechanism there.
See Also: javax.jdo.PersistenceManager.detachCopyAll(java.util.Collection) |
extractSqlStringFromException | protected String extractSqlStringFromException(JDOException ex)(Code) | | 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.
Parameters: ex - the JDOException, containing a SQLException the SQL String, or null if none found |
flush | public void flush(PersistenceManager pm) throws JDOException(Code) | | This implementation delegates to JDO 2.0's flush method.
To be overridden for pre-JDO2 implementations, using the corresponding
vendor-specific mechanism there.
See Also: javax.jdo.PersistenceManager.flush |
getJdbcConnection | public ConnectionHandle getJdbcConnection(PersistenceManager pm, boolean readOnly) throws JDOException, SQLException(Code) | | 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 ).
See Also: javax.jdo.PersistenceManager.getDataStoreConnection See Also: org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor See Also: org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection |
getJdbcExceptionTranslator | public SQLExceptionTranslator getJdbcExceptionTranslator()(Code) | | Return the JDBC exception translator for this dialect, if any.
|
newNamedQuery | public Query newNamedQuery(PersistenceManager pm, Class entityClass, String queryName) throws JDOException(Code) | | This implementation delegates to JDO 2.0's newNamedQuery method.
To be overridden for pre-JDO2 implementations, using the corresponding
vendor-specific mechanism there.
See Also: javax.jdo.PersistenceManager.newNamedQuery(ClassString) |
releaseJdbcConnection | public void releaseJdbcConnection(ConnectionHandle conHandle, PersistenceManager pm) throws JDOException, SQLException(Code) | | 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.
See Also: java.sql.Connection.close |
|
|