One of the most common ways for a Java application to interact with a database is with some JPA implementation. We'll use the Hibernate implementation for these examples, though any JPA implementation will work. The JPA spec, and the ObjectGrid APIs, contain many parallels, which make learning the integration concepts much easier. The JPA spec most closely matches the EntityManager API in terms of interacting with persistent data. In fact, both classes used for interacting with persistent data are EntityManagers, though they are in different packages. Due to similarities in class and method names, we'll configure JPA and ObjectGrid differently. We'll use the ObjectGrid annotations and the JPA XML configuration when the class and annotation names overlap.
We need to configure our application models to use JPA. This means we create our persistence.xml
and orm.xml
files as we normally would for JPA:
File: persistence.xml <?xml version="1.0" encoding="UTF-8...