I'm currently playing with Google App Engine, the cloud computing platform from Google. In this platform, you're allowed to use two orm technologies: JDO and JPA.
I've been setting up spring to manage JDO persistence. First step, is adding Spring listener in web.xml:
Then, create an application context file in war/WEB-INF/applicationContext.xml:
Take a look at the first bean, persistenceManagerFactory. This bean acts as your Persistence Manager Factory. To link with GAE's jdo you must set the property persistenceManagerFactoryName with the name of your persistence-manager-factory that is located in src/META-INF/jdoconfig.xml. By default, when you create a GAE's project with eclipse, this name is transactional-optional.
This setup, uses the helper class org.springframework.orm.jdo.JdoTemplate. Is a very common pattern in Spring's orm. JdoTemplate contains very usual methods to work with jdo, methods to persist objects and query methods. To inject this template in your DAOs you must extend org.springframework.orm.jdo.support.JdoDaoSupport in all of them.
There is another way to setup your DAOs. Instead of extend JdoDaoSupport, you can inject directly your Persistence Manager Factory. Take a look at this article for detailed instructions. The problem with this setup is that you lost all methods available in JdoTemplate but, you gain more control over JDO.
viernes, 14 de mayo de 2010
Suscribirse a:
Comentarios (Atom)