Skip to content

Latest commit

 

History

History
92 lines (69 loc) · 3.57 KB

introduction.adoc

File metadata and controls

92 lines (69 loc) · 3.57 KB

Introduction

One API, Multiple Databases

Jakarta NoSQL is a Java framework that streamlines the integration of Java applications with NoSQL databases.

It uses the same annotations to map Java objects. Therefore, with just these annotations, whose names match those from the Jakarta Persistence specification, there is support for several NoSQL database types.

@Entity
public class Book {

    @Id
    private String isbn;

    @Column
    private String title;

    @Column
    private String description;
 //...
}

Developers must consider low cognitive load when choosing a NoSQL database for their applications. For example, if there is a need to switch out a database, considerations include the time spent on the change; the learning curve of a new database API; the code that will be lost; the persistence layer that needs to be replaced, etc. Jakarta NoSQL avoids most of these issues through the API.

Jakarta NoSQL also provides Template classes that apply the Template Method design pattern to all database operations.

Beyond Jakarta Persistence (JPA)

The Jakarta Persistence specification is an excellent API for object-relational mapping and has established itself as a Jakarta EE standard. It would be ideal to use the same API for both SQL and NoSQL, but there are behaviors in NoSQL that SQL does not cover, such as time-to-live and asynchronous operations. Jakarta Persistence was simply not designed to handle those features.

ColumnTemplate template = // instance; a template to document NoSQL operations
Deity diana = Deity.builder()
        .withId("diana")
        .withName("Diana")
        .withPower("hunt")
        .build();

Duration ttl = Duration.ofSeconds(1);
template.insert(diana, ttl);

A Fluent API

Jakarta NoSQL is a fluent API for Java developers to more easily create queries that either retrieve or delete information in a NoSQL database type. For example:

Template template = // instance; a template to document NoSQL operations
Deity diana = Deity.builder()
        .withId("diana")
        .withName("Diana")
        .withPower("hunt")
        .build();

template.insert(diana);// insert an entity

List<Deity> deities = template.select(Deity.class)
        .where("name")
        .eq("Diana").result(); // SELECT Deity WHERE name equals “Diana”

template.delete(Deity.class).where("name")
        .eq("Diana").execute();

Key Features

  • Simple APIs that support all well-known NoSQL storage types.

  • Specialized NoSQL types: Key-Value, Column Family, Document databases

  • Use of Convention Over Configuration

  • Easy-to-implement API Specification and Technology Compatibility Kit (TCK) for NoSQL Vendors

  • The API’s focus is on simplicity and ease of use. Developers should only know minimal artifacts to work with Jakarta NoSQL.