Proxy for a target JDO
javax.jdo.PersistenceManagerFactory ,
returning the current thread-bound PersistenceManager (the Spring-managed
transactional PersistenceManager or a the single OpenPersistenceManagerInView
PersistenceManager) on getPersistenceManager() , if any.
Essentially, getPersistenceManager() calls get seamlessly
forwarded to
PersistenceManagerFactoryUtils.getPersistenceManager .
Furthermore, PersistenceManager.close calls get forwarded to
PersistenceManagerFactoryUtils.releasePersistenceManager .
The main advantage of this proxy is that it allows DAOs to work with a
plain JDO PersistenceManagerFactory reference, while still participating in
Spring's (or a J2EE server's) resource and transaction management. DAOs will
only rely on the JDO API in such a scenario, without any Spring dependencies.
Note that the behavior of this proxy matches the behavior that the JDO spec
defines for a PersistenceManagerFactory as exposed by a JCA connector, when
deployed in a J2EE server. Hence, DAOs could seamlessly switch between a JNDI
PersistenceManagerFactory and this proxy for a local PersistenceManagerFactory,
receiving the reference through Dependency Injection. This will work without
any Spring API dependencies in the DAO code!
It is usually preferable to write your JDO-based DAOs with Spring's
JdoTemplate , offering benefits such as consistent data access
exceptions instead of JDOExceptions at the DAO layer. However, Spring's
resource and transaction management (and Dependency Injection) will work
for DAOs written against the plain JDO API as well.
Of course, you can still access the target PersistenceManagerFactory
even when your DAOs go through this proxy, by defining a bean reference
that points directly at your target PersistenceManagerFactory bean.
author: Juergen Hoeller since: 1.2 See Also: javax.jdo.PersistenceManagerFactory.getPersistenceManager See Also: javax.jdo.PersistenceManager.close See Also: PersistenceManagerFactoryUtils.getPersistenceManager See Also: PersistenceManagerFactoryUtils.releasePersistenceManager |