| org.springframework.orm.jdo.JdoDialect
All known Subclasses: org.springframework.orm.jdo.DefaultJdoDialect,
JdoDialect | public interface JdoDialect (Code) | | SPI strategy that allows for customizing integration with a specific JDO provider,
in particular regarding transaction management and exception translation. To be
implemented for specific JDO providers such as JPOX, Kodo, Lido, Versant Open Access.
JDO 2.0 defines standard ways for most of the functionality covered here.
Hence, Spring's
DefaultJdoDialect uses the corresponding JDO 2.0 methods
by default, to be overridden in a vendor-specific fashion if necessary.
Vendor-specific subclasses of
DefaultJdoDialect are still required for special
transaction semantics and more sophisticated exception translation (if needed).
In general, it is recommended to derive from
DefaultJdoDialect instead
of implementing this interface directly. This allows for inheriting common
behavior (present and future) from
DefaultJdoDialect , only overriding
specific hooks to plug in concrete vendor-specific behavior.
author: Juergen Hoeller since: 02.11.2003 See Also: JdoTransactionManager.setJdoDialect See Also: JdoAccessor.setJdoDialect See Also: DefaultJdoDialect |
Method Summary | |
void | applyQueryTimeout(Query query, int timeout) Apply the given timeout to the given JDO query object. | Object | beginTransaction(Transaction transaction, TransactionDefinition definition) Begin the given JDO transaction, applying the semantics specified by the
given Spring transaction definition (in particular, an isolation level
and a timeout). | void | cleanupTransaction(Object transactionData) Clean up the transaction via the given transaction data.
Invoked by JdoTransactionManager on transaction cleanup.
An implementation can, for example, reset read-only flag and
isolation level of the underlying JDBC Connection. | void | flush(PersistenceManager pm) Flush the given PersistenceManager, i.e. | ConnectionHandle | getJdbcConnection(PersistenceManager pm, boolean readOnly) Retrieve the JDBC Connection that the given JDO PersistenceManager uses underneath,
if accessing a relational database. | void | releaseJdbcConnection(ConnectionHandle conHandle, PersistenceManager pm) Release the given JDBC Connection, which has originally been retrieved
via getJdbcConnection . | DataAccessException | translateException(JDOException ex) Translate the given JDOException to a corresponding exception from Spring's
generic DataAccessException hierarchy. |
applyQueryTimeout | void applyQueryTimeout(Query query, int timeout) throws JDOException(Code) | | Apply the given timeout to the given JDO query object.
Invoked with the remaining time of a specified transaction timeout, if any.
Parameters: query - the JDO query object to apply the timeout to Parameters: timeout - the timeout value to apply throws: JDOException - if thrown by JDO methods See Also: JdoTemplate.prepareQuery |
beginTransaction | Object beginTransaction(Transaction transaction, TransactionDefinition definition) throws JDOException, SQLException, TransactionException(Code) | | Begin the given JDO transaction, applying the semantics specified by the
given Spring transaction definition (in particular, an isolation level
and a timeout). Invoked by JdoTransactionManager on transaction begin.
An implementation can configure the JDO Transaction object and then
invoke begin , or invoke a special begin method that takes,
for example, an isolation level.
An implementation can also apply read-only flag and isolation level to the
underlying JDBC Connection before beginning the transaction. In that case,
a transaction data object can be returned that holds the previous isolation
level (and possibly other data), to be reset in cleanupTransaction .
Implementations can also use the Spring transaction name, as exposed by the
passed-in TransactionDefinition, to optimize for specific data access use cases
(effectively using the current transaction name as use case identifier).
Parameters: transaction - the JDO transaction to begin Parameters: definition - the Spring transaction definition that defines semantics an arbitrary object that holds transaction data, if any(to be passed into cleanupTransaction) throws: JDOException - if thrown by JDO methods throws: SQLException - if thrown by JDBC methods throws: TransactionException - in case of invalid arguments See Also: JdoDialect.cleanupTransaction See Also: javax.jdo.Transaction.begin See Also: org.springframework.jdbc.datasource.DataSourceUtils.prepareConnectionForTransaction |
flush | void flush(PersistenceManager pm) throws JDOException(Code) | | Flush the given PersistenceManager, i.e. flush all changes (that have been
applied to persistent objects) to the underlying database. This method will
just get invoked when eager flushing is actually necessary, for example when
JDBC access code needs to see changes within the same transaction.
Parameters: pm - the current JDO PersistenceManager throws: JDOException - in case of errors See Also: JdoAccessor.setFlushEager |
getJdbcConnection | ConnectionHandle getJdbcConnection(PersistenceManager pm, boolean readOnly) throws JDOException, SQLException(Code) | | Retrieve the JDBC Connection that the given JDO PersistenceManager uses underneath,
if accessing a relational database. This method will just get invoked if actually
needing access to the underlying JDBC Connection, usually within an active JDO
transaction (for example, by JdoTransactionManager). The returned handle will
be passed into the releaseJdbcConnection method when not needed anymore.
Implementations are encouraged to return an unwrapped Connection object, i.e.
the Connection as they got it from the connection pool. This makes it easier for
application code to get at the underlying native JDBC Connection, like an
OracleConnection, which is sometimes necessary for LOB handling etc. We assume
that calling code knows how to properly handle the returned Connection object.
In a simple case where the returned Connection will be auto-closed with the
PersistenceManager or can be released via the Connection object itself, an
implementation can return a SimpleConnectionHandle that just contains the
Connection. If some other object is needed in releaseJdbcConnection ,
an implementation should use a special handle that references that other object.
Parameters: pm - the current JDO PersistenceManager Parameters: readOnly - whether the Connection is only needed for read-only purposes a handle for the JDBC Connection, to be passed intoreleaseJdbcConnection , or null if no JDBC Connection can be retrieved throws: JDOException - if thrown by JDO methods throws: SQLException - if thrown by JDBC methods See Also: JdoDialect.releaseJdbcConnection See Also: org.springframework.jdbc.datasource.ConnectionHandle.getConnection See Also: org.springframework.jdbc.datasource.SimpleConnectionHandle See Also: JdoTransactionManager.setDataSource See Also: org.springframework.jdbc.support.nativejdbc.NativeJdbcExtractor |
releaseJdbcConnection | void releaseJdbcConnection(ConnectionHandle conHandle, PersistenceManager pm) throws JDOException, SQLException(Code) | | Release the given JDBC Connection, which has originally been retrieved
via getJdbcConnection . This should be invoked in any case,
to allow for proper release of the retrieved Connection handle.
An implementation might simply do nothing, if the Connection returned
by getJdbcConnection will be implicitly closed when the JDO
transaction completes or when the PersistenceManager is closed.
Parameters: conHandle - the JDBC Connection handle to release Parameters: pm - the current JDO PersistenceManager throws: JDOException - if thrown by JDO methods throws: SQLException - if thrown by JDBC methods See Also: JdoDialect.getJdbcConnection |
|
|