Jpalite

Lightweight JPA in a nutshell
The Java Persistence API (JPA) is a Java specification for accessing, persisting, and managing data between Java objects / classes and a relational database. Wikibooks

Lightweight is always relative to something which is "heavyweight". With the Java Persistence API, any attempt to cover it comprehensively will result in a heavyweight implementation. Take the Apache Open JPA project for example. You can download the source code and with a simple metrics exercise work out this a major, complex piece of technology. It comes as a surprise then that these words appear in the manual:

Lightweight persistence is the storage and retrieval of persistent data with little or no work from you, the developer. Apache OpenJPA 2.3 User's Guide

Therefore an important point is that Lightweight JPA here means the implementation can run in an environment which has significant resource constraints such as a mobile device. The motivation for the Java developer is to take advantage of the ease with which of application objects can be persisted to a database without the hassle of having to write boilerplate database code.

ORMLite Foundation

Jpalite places a thin layer over Object to Relational Mapping package OrmLite. This package is popular with Android developers and even offers some Javax Persistence annotations as alternatives to it's own.

The key component of OrmLite is the Data Access Object (DAO) which encapsulates all the available persistence operations tied to one ORM class. Although DAOs are used extensively, they are hidden from view. However, a single EntityManagerLte method does provide access to DAO's in case a need is found to do this. A DAO is referenced by the entity class it manages.

The only part of Ormlite for which some insight is required is the Custom Statement Builder which is used to create named queries.

An important characteristic of OrmLite is that is designed to work in applications where only one session is accessing a database at any time. Providing transaction isolation and database locking in a multi-session context depends on utilizing available database capabilities.

Jpalite Persistence

In brief, these are the JPA features which have been applied to OrmLite:

  1. Define persistence units, entity classes and database details with jpalite.jsonl
  2. Improved ManyToMany and OneToMany annotation implementations
  3. Lightweight EntityManager and PersistenceContainer JPA implementations
  4. Container managed transactions.
  5. Execute native and OrmLite named queries
  6. Handlers for database creation or version update

Here is the jpalite.json configuration from the Many to Many Sample

Persistence configuration