meg*_*ord 191 java spring persistence dao jdo
我正在尝试使用org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy
我的Spring项目,但我不确定如何使用它或者它是否正是我正在寻找的.我意识到它可以帮助我的DAO使用简单的JDO PersistenceManagerFactory
.另一个问题是:如果代理没有正确完成会发生什么?我还可以使用它来访问我的工厂来创建一个事务感知持久性管理器吗?如果工厂管理的对象是单例,这会改变吗?为什么不直接访问PersistenceManagerFactory?也许PersistenceManagerFactoryUtils.getPersistenceManager
更适合我的需求?可以getObject
返回null吗?
Cha*_*ara 20
Answers are directly available on documentation
I realize it can help make my DAOs work with a plain JDO PersistenceManagerFactory.
Yes. TransactionAwarePersistenceManagerFactoryProxy proxy 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. You can surely use it in your app. But without knowing your exact needs, we can't confirm any further.
Can I still use it to access my factory to create a transaction aware persistence manager
DAOs could seamlessly switch between a JNDI PersistenceManagerFactory and this proxy for a local PersistenceManagerFactory.
If the object managed by the factory is a singleton, does this change things? Why not just access the PersistenceManagerFactory directly?
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.
归档时间: |
|
查看次数: |
27846 次 |
最近记录: |