|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.orm.jdo.DefaultJdoDialect
Default implementation of the JdoDialect interface. Used by JdoAccessor and JdoTransactionManager as default.
Simply begins a standard JDO transaction in beginTransaction
.
Returns null on getJdbcConnection
.
Ignores a given query timeout in applyQueryTimeout
.
Throws a JDOUnsupportedOptionException on flush
.
Delegates to PersistenceManagerFactoryUtils for exception translation.
This class will be adapted to JDO 2.0 as soon as the latter is available. JDBC Connection retrieval and flushing will then default to the respective JDO 2.0 methods. Vendor-specific subclasses will still be necessary for special transaction semantics and more sophisticated exception translation.
JdoAccessor.setJdoDialect(org.springframework.orm.jdo.JdoDialect)
,
JdoTransactionManager.setJdoDialect(org.springframework.orm.jdo.JdoDialect)
Field Summary | |
protected Log |
logger
|
Constructor Summary | |
DefaultJdoDialect()
Create a new DefaultJdoDialect. |
|
DefaultJdoDialect(javax.jdo.PersistenceManagerFactory pmf)
Create a new DefaultJdoDialect. |
Method Summary | |
void |
afterPropertiesSet()
Eagerly initialize the exception translator, creating a default one for the specified PersistenceManagerFactory if none set. |
void |
applyQueryTimeout(javax.jdo.Query query,
int remainingTimeInSeconds)
This implementation logs a warning that it cannot apply a query timeout. |
Object |
beginTransaction(javax.jdo.Transaction transaction,
TransactionDefinition definition)
This implementation invokes the standard JDO Transaction.begin
method. |
void |
cleanupTransaction(Object transactionData)
This implementation does nothing, as the default beginTransaction implementation does not require any cleanup. |
void |
flush(javax.jdo.PersistenceManager pm)
This implementation throws a JDOUnsupportedOptionException. |
ConnectionHandle |
getJdbcConnection(javax.jdo.PersistenceManager pm,
boolean readOnly)
This implementation returns null, to indicate that JDBC Connection retrieval is not supported. |
SQLExceptionTranslator |
getJdbcExceptionTranslator()
Return the JDBC exception translator for this instance. |
javax.jdo.PersistenceManagerFactory |
getPersistenceManagerFactory()
Return the JDO PersistenceManagerFactory that should be used to create PersistenceManagers. |
void |
releaseJdbcConnection(ConnectionHandle conHandle,
javax.jdo.PersistenceManager pm)
This implementation does nothing, assuming that the Connection will implicitly be closed with the PersistenceManager. |
void |
setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
Set the JDBC exception translator for this dialect. |
void |
setPersistenceManagerFactory(javax.jdo.PersistenceManagerFactory pmf)
Set the JDO PersistenceManagerFactory, which is used to initialize the default JDBC exception translator if none specified. |
DataAccessException |
translateException(javax.jdo.JDOException ex)
This implementation delegates to PersistenceManagerFactoryUtils. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Log logger
Constructor Detail |
public DefaultJdoDialect()
public DefaultJdoDialect(javax.jdo.PersistenceManagerFactory pmf)
pmf
- the JDO PersistenceManagerFactory, which is used
to initialize the default JDBC exception translatorMethod Detail |
public void setPersistenceManagerFactory(javax.jdo.PersistenceManagerFactory pmf)
setJdbcExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator)
public javax.jdo.PersistenceManagerFactory getPersistenceManagerFactory()
public void setJdbcExceptionTranslator(SQLExceptionTranslator jdbcExceptionTranslator)
The default exception translator is either a SQLErrorCodeSQLExceptionTranslator if a DataSource is available, or a SQLStateSQLExceptionTranslator else.
jdbcExceptionTranslator
- exception translatorSQLException
,
JDOException.getCause()
,
PersistenceManagerFactoryUtils.newJdbcExceptionTranslator(javax.jdo.PersistenceManagerFactory)
,
SQLErrorCodeSQLExceptionTranslator
,
SQLStateSQLExceptionTranslator
public SQLExceptionTranslator getJdbcExceptionTranslator()
public void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
public Object beginTransaction(javax.jdo.Transaction transaction, TransactionDefinition definition) throws javax.jdo.JDOException, SQLException, TransactionException
Transaction.begin
method. Throws an InvalidIsolationLevelException if a non-default isolation
level is set.
beginTransaction
in interface JdoDialect
transaction
- the JDO transaction to begindefinition
- the Spring transaction definition that defines semantics
TransactionException
- in case of invalid arguments
javax.jdo.JDOException
- if thrown by JDO methods
SQLException
- if thrown by JDBC methodsTransaction.begin()
,
InvalidIsolationLevelException
public void cleanupTransaction(Object transactionData)
cleanupTransaction
in interface JdoDialect
transactionData
- arbitrary object that holds transaction data, if any
(as returned by beginTransaction)beginTransaction(javax.jdo.Transaction, org.springframework.transaction.TransactionDefinition)
public ConnectionHandle getJdbcConnection(javax.jdo.PersistenceManager pm, boolean readOnly) throws javax.jdo.JDOException, SQLException
getJdbcConnection
in interface JdoDialect
pm
- the current JDO PersistenceManager
releaseJdbcConnection
, or null if no JDBC Connection can be retrieved
javax.jdo.JDOException
- if thrown by JDO methods
SQLException
- if thrown by JDBC methodsJdoDialect.releaseJdbcConnection(org.springframework.jdbc.datasource.ConnectionHandle, javax.jdo.PersistenceManager)
,
ConnectionHandle.getConnection()
,
SimpleConnectionHandle
,
JdoTransactionManager.setDataSource(javax.sql.DataSource)
,
NativeJdbcExtractor
public void releaseJdbcConnection(ConnectionHandle conHandle, javax.jdo.PersistenceManager pm) throws javax.jdo.JDOException, SQLException
If the JDO implementation returns a Connection handle that
it expects the application to close, the dialect needs to invoke
Connection.close
here.
releaseJdbcConnection
in interface JdoDialect
conHandle
- the JDBC Connection handle to releasepm
- the current JDO PersistenceManager
javax.jdo.JDOException
- if thrown by JDO methods
SQLException
- if thrown by JDBC methodsConnection.close()
public void applyQueryTimeout(javax.jdo.Query query, int remainingTimeInSeconds) throws javax.jdo.JDOException
applyQueryTimeout
in interface JdoDialect
query
- the JDO query object to apply the timeout toremainingTimeInSeconds
- the timeout value to apply
javax.jdo.JDOException
- if thrown by JDO methodsJdoTemplate.prepareQuery(javax.jdo.Query)
public void flush(javax.jdo.PersistenceManager pm) throws javax.jdo.JDOException
flush
in interface JdoDialect
pm
- the current JDO PersistenceManager
javax.jdo.JDOException
- in case of errorsJDOUnsupportedOptionException
public DataAccessException translateException(javax.jdo.JDOException ex)
translateException
in interface JdoDialect
ex
- the JDOException thrown
PersistenceManagerFactoryUtils.convertJdoAccessException(javax.jdo.JDOException)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |