org.springframework.dao
exception hierarchy. The central method is execute
, supporting JDO access code implementing the {@link JdoCallback} interface. It provides JDO PersistenceManagerhandling such that neither the JdoCallback implementation nor the calling code needs to explicitly care about retrieving/closing PersistenceManagers, or handling JDO lifecycle exceptions.
Typically used to implement data access or business logic services that use JDO within their implementation but are JDO-agnostic in their interface. The latter or code calling the latter only have to deal with business objects, query objects, and org.springframework.dao
exceptions.
Can be used within a service implementation via direct instantiation with a PersistenceManagerFactory reference, or get prepared in an application context and given to services as bean reference. Note: The PersistenceManagerFactory should always be configured as bean in the application context, in the first case given to the service directly, in the second case to the prepared template.
This class can be considered as direct alternative to working with the raw JDO PersistenceManager API (through PersistenceManagerFactoryUtils.getPersistenceManager()
). The major advantage is its automatic conversion to DataAccessExceptions, the major disadvantage that no checked application exceptions can get thrown from within data access code. Corresponding checks and the actual throwing of such exceptions can often be deferred to after callback execution, though.
{@link LocalPersistenceManagerFactoryBean} is the preferred way of obtaininga reference to a specific PersistenceManagerFactory, at least in a non-EJB environment. The Spring application context will manage its lifecycle, initializing and shutting down the factory as part of the application.
Note that lazy loading will just work with an open JDO PersistenceManager, either within a Spring-driven transaction (with JdoTransactionManager or JtaTransactionManager) or within OpenPersistenceManagerInViewFilter/Interceptor. Furthermore, some operations just make sense within transactions, for example: evict
, evictAll
, flush
.
NOTE: This class requires JDO 2.0 or higher, as of Spring 2.5. @author Juergen Hoeller @since 03.06.2003 @see #setPersistenceManagerFactory @see JdoCallback @see javax.jdo.PersistenceManager @see LocalPersistenceManagerFactoryBean @see JdoTransactionManager @see org.springframework.transaction.jta.JtaTransactionManager @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewFilter @see org.springframework.orm.jdo.support.OpenPersistenceManagerInViewInterceptor
|
|
|
|
|
|
|
|
|
|