Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsure if I understand TransactionAwarePersistenceManagerFactoryProxy

I am trying to use the org.springframework.orm.jdo.TransactionAwarePersistenceManagerFactoryProxy in my Spring project, but I am not sure how to use it or whether it's exactly what I am looking for. I realize it can help make my DAOs work with a plain JDO PersistenceManagerFactory. Another question is: what happens if the proxy doesn't get made properly? Can I still use it to access my factory to create a transaction aware persistence manager? If the object managed by the factory is a singleton, does this change things? Why not just access the PersistenceManagerFactory directly? Perhaps PersistenceManagerFactoryUtils.getPersistenceManager would be more suited to my needs? Can getObject return null?

like image 663
megazord Avatar asked Oct 15 '22 07:10

megazord


1 Answers

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.

like image 21
Chand Priyankara Avatar answered Oct 16 '22 19:10

Chand Priyankara