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.
If you have been through the previous chapter on JPA, this chapter won’t come as a surprise.
EntityManagerFactory in JPA, there’s a
factory class in JDO as well:
EntityManager was the core of JPA,
PersistenceManager is used similarly within the JDO world. Use the
factory object to fetch your
accordingly invoke the relevant data access operations.
Spring can help your application development in a couple of ways. You can either work with
JdoTemplate or use a plain JDO API.
While Spring provides the convenient
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 ...