Chapter 5. Spring JDO

Java Data Objects (JDO) is yet another Java standard for persisting the Java POJOs. We have already seen JPA in Chapter 4. This chapter concentrates on JDO aspects of data access, how the Spring framework helps in configuring and using JDO in our Java applications. While JPA mainly works against relational databases, JDO is database-agnostic. You can think of any type of data stores such as object databases, NoSQL data stores, filesystems, email, XML, and so on.

In this chapter, we will look at the primary interfaces that JDO specification defines and how Spring provides support for using JDO-compliant providers in our Java application. As expected, the Spring framework is mainly used for dependency injection.

Spring Support

If you have been through the previous chapter on JPA, this chapter won’t come as a surprise.

Similar to EntityManagerFactory in JPA, there’s a factory class in JDO as well: PersistenceManagerFactory. Just as EntityManager was the core of JPA, PersistenceManager is used similarly within the JDO world. Use the factory object to fetch your PersistenceManager and accordingly invoke the relevant data access operations.

Spring can help your application development in a couple of ways. You can either work with a standard JdoTemplate or use a plain JDO API.

While Spring provides the convenient JdoTemplate, the preferred way of doing things since Spring version 3 is to use the native APIs while allowing Spring to inject the necessary factories.

So let’s ...

Get Just Spring Data Access now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.