Product Documentation

JPA and Hibernate Persistence APIs

Previous Topic

Next Topic

c-treeDB JPA Interface Technology

The FairCom DB Java Persistence API, commonly referred to as c-treeDB JPA, provides Java developers a unique record-oriented, non-SQL, Java framework to persist data using the FairCom DB ISAM Database Engine.

Resources

Our intent is to have you up and running as quickly as possible, so please proceed to the Quick Start below. After the Quick Start, we've provided links to additional resources to aid in your development cycle.

  • QuickStart - Get up and running quickly.
  • Java - Visit Oracle's Java learning web site.

The Java Persistence API

The Java Persistence API (JPA) is defined as part of the EJB 3.0 specification for accessing, persisting, and managing data between Java objects/classes and a relational database. JPA is the standard approach for Object to Relational Mapping (ORM) in Java.

JPA is a specification for a set of interfaces; open-source and commercial JPA implementations are available. JPA requires a database to hold the persisted objects. Most, if not all, Java EE 5 application servers should support JPA.

JPA allows POJO (Plain Old Java Objects) to be persisted without implementing any interfaces or methods (as was required by the EJB 2 CMP specification). Using JPA, the object-relational mappings for an object (defining how the Java class maps to a relational database table) can be defined through standard annotations or XML. JPA defines a runtime EntityManager API, which processes queries and transactions. JPA provides an object-level query language, JPQL for querying the database.

EclipseLink is the JPA implementation used with the FairCom Server. It is a reference implementation of the JPA 2.1 specification which has been extended to support non-relational (NoSQL) databases.

Benefits

The advantage of using JPA over other Java persistence technologies is that it is very easy to set up and use. Other APIs require you to implement or extend superclasses or interfaces or to write huge and clumsy XML files. With JPA you only need to annotate a model class (business object) with @Entity and you need an ID field that you annotate with @Id.

You can tell JPA to store instances of those annotated classes. You can load them using the ID value or using a query language similar to SQL called JPQL.

What requires 100 lines of code in other Java persistence technologies takes only 10 when you use JPA.


Platform Dependence

The NoSQL JPA plugin for EclipseLink uses the FairCom DB JTDB API, which is currently not platform-independent. The plugin needs one DLL or .so file in the system path. The FairCom DB dialect for Hibernate does not have this limitation because it uses the FairCom DB JDBC driver and the FairCom DB SQL Server. The FairCom DB JDBC driver does not rely on a DLL or .so file to function, which makes it a more platform-independent solution. However benchmarks have shown the NoSQL approach to be significantly faster because it cuts through all the SQL layers.

Similarly if you use the JDBC API directly you also do not rely on any DLL or .so files.

In summary, if your platform allows binary library files like DLL or .so files, FairCom recommends using the NoSQL JPA variant.

Implementation

The JPA implementation used with the FairCom Server is EclipseLink, the reference implementation of the JPA 2.1 specification. Support for a new database is added by writing a plugin that conforms to the JCA and CCI APIs. FairCom has written such a plugin for EclipseLink based with our Java navigational API.

You will need the following from your FairCom DB package:

  • EclipseLink version 2.6.1 (can be downloaded from eclipse.org)

    and

  • FairCom DB JPA plugin (located in the drivers/java.jpa.nav folder)

In This Chapter

Quick Start

Additional Resources and Functionality

TOCIndex