Product Documentation

c-treeDB Java Persistence API (JPA)

Previous Topic

Next Topic

Getting Started with c-treeDB JPA

This driver was developed using EclipseLink version 2.6.1 and Java version 8.

Inside the driver folder you will find the following files and folders:

  • FairComCtreeDB.jar - The standard c-treeDB Java navigational API.
  • or mtclijni64.dll - a client-side library needed by c-treeDB Java.
  • FairComCtreeDB_JPA.jar - The EclipseLink JPA driver.
  • tutorials - The folder with an example project using the Gradle build system.

You do not need to install Gradle for the tutorial to work. But you do need a working internet connection, because the tutorial build script will download all the necessary files for it to work.

Be sure you have Java 8, 9, 11, 15, or 16 installed and then access the tutorials folder using a command-line interface. On Windows, you can use the “Apps & Features” control to list the installed programs, and it will show which Java version you have installed.

Execute one of the following based on which operating system you are using:


> make build; make run


> BuildTutorials.bat

The first time you run the tutorial, the program will create an ‘Email’ table, and you will see output like this (in addition to the output that is emitted by Gradle):

creating table: Email

creating field: id

creating field: sender

creating field: subject

creating field: textpreview

creating field: hash

creating field: tags

creating field: archived

creating field: received

creating field: created

Subsequent runs of the tutorial will not create the ‘Email’ table, because it already exists, so the above text will not be emitted.

In This Chapter

Adjusting the Connection Information

How to Start Your Own Project

Previous Topic

Next Topic

Adjusting the Connection Information

The connection information is stored in the persistence.xml file. It can be found here in the following location:


Previous Topic

Next Topic

How to Start Your Own Project

The best way to start your own project is to copy the tutorials folder and rename it. Then follow these steps to create your project:

  1. Rename the project name in the settings.gradle file.
  2. Copy the c-treeDB Java and JPA driver files to a lib subfolder.
  3. Modify the build.gradle file and adjust the java.library.path systemProperty to point to the location of the native libraries.
  4. Depending on your environment, you might need to adapt the persistence.xml file.
  5. It is a good idea to rename the persistence-unit from TestJPAPU to something resembling your environment or project. If you do so, remember to also change this in the call to createEntityManagerFactory if you don't use a Java EE application server.
  6. Create one or more entity classes to persist your application data. Remember to annotate them with: @NoSql(dataFormat = DataFormatType.MAPPED) and each field with @Field(name = "yourname")
  7. Add each entity class name to the persistence.xml file.
  8. Finally, create or use the EntityManager in a real program to persist and load your application data.

Contact FairCom if you have any questions about this process.