Product Documentation

JPA and Hibernate Persistence APIs

Previous Topic

Next Topic

Usage with Java Standard Edition

To use with the Java standard edition:

  1. Start a new or open an existing Java project.
  2. Add the following files to the Java classpath (these files are part of NetBeans and are freely available from the Eclipse downloads page):
    • eclipselink26x.jar
    • javax.persistence_2.1.0.v201304241213.jar (this jar is found in eclipselink-2.6.1.v20150916-55dc7c3.zip)
    • javax.resource_1.6.0.v201204270900.jar (this jar is found in eclipselink-plugins-nosql-2.6.1.v20150916-55dc7c3.zip)
  3. Add the following files found in lib\ctree.isam.jpa to the Java classpath:
    • FairComCtreeDB_JPA.jar
    • FairComCtreeDB.jar
  4. Add one of both of the following files (found in lib\ctree.isam.jpa) to the system path:
    • mtclijni32.dll
    • mtclijni64.dll
  5. Create a folder called META-INF in the source code root directory and edit persistence.xml to appear as shown below (this file is also available in ctree.isam.jpa\tutorials):

    persistence.xml

  6. Create a new folder structure in the source code root directory to host your entities, for example: com/demo/model. Create Email.java as shown in the example below (this file is also available in ctree.isam.jpa\tutorials):

    email.java


Be sure to note the following annotations:

  • @NoSQL - This annotation triggers the NoSQL API inside EclipseLink. It also tells EclipseLink what data format to use to pass the entities data to the NoSQL plug-in. In the case of c-tree, the correct data format is Mapped.
  • @Field - The @Field annotations—complete with the name parameter—are currently needed to make sure the data is read out of the database correctly when using query operations. This requirement may be relaxed in the future, but for now they are required.


Here is a sample of JPA test code to get you started:

JPA Sample


Please make sure that you have created the database that is referenced in the persistence .xml file.

If you execute the code above with the FairCom DB NoSQL server running you should see that the EntityManager has created a new Table called Email and that is has stored the Email in your new table and that it has generated a new unique ID for it, both in Java and in the database.

TOCIndex