Product Documentation

c-treeACE V11.0 Update Guide

Previous Topic

Next Topic

Java Persistence API (JPA) with c-treeACE

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.

Java persistence consists of four areas:

  • The Java Persistence API
  • The query language
  • The Java Persistence Criteria API
  • Object/relational mapping metadata

Common JPA implementations, such as Hibernate, map data interactions to relational SQL commands with a RDBMS to persist data and is fully supported with c-treeACE SQL and JDBC.

c-treeDB JPA is a novel new navigational (NoSQL) implementation: Instead of mapping to relational SQL, we map to our ISAM interface, benefiting from reduced resource usage and improved performance.

Current JPA Java applications can easily switch to the FairCom’s c-treeDB JPA and take advantage of our ISAM persistence implementation without application changes. Remove additional unneeded SQL depending on the type of application.

FairCom’s c-treeDB JPA replaces Hibernate and your RDBMS from any application that has been developed using this architecture.

Java Duke Glasses

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.

Implementation

The JPA implementation used with the FairCom Server is EclipseLink, the reference implementation of the JPA 2.1 specification. In 2012 it began an effort to support NoSQL databases. Support for a new NoSQL database is added by writing a plugin that conforms to the JCA and CCI APIs. FairCom has written such a plugin for EclipseLink based on its JTDB Java API.

You will need EclipseLink version 2.6.1 and the c-treeACE NoSQL plugin. Both can be found in the c-treeACE package.

Limitations

The NoSQL JPA plugin for EclipseLink uses the c-treeACE JTDB API, which is currently not platform-independent. The plugin needs one DLL or .so file in the system path. The c-treeACE dialect for Hibernate does not have this limitation because it uses the c-treeACE JDBC driver and the c-treeACE SQL Server. The c-treeACE 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.

TOCIndex