Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Jakarta Data and NoSQL - Standardized Data Acce...

Jakarta Data and NoSQL - Standardized Data Access for Jakarta EE

The amount of data collected by applications nowadays is growing rapidly. Many of them need to support both relational SQL and non-relational NoSQL databases. Jakarta Data provides an API to allow easy data access. Developers can split the persistence mechanism and the model using common features like the Repository pattern and seamlessly switch between SQL and NoSQL databases or even use both in the same application.

First we'll introduce the concept of NoSQL database systems, the different types of NoSQL databases and how SQL and NoSQL differ from each other.
Followed by an overview of Jakarta Data and Jakarta NoSQL, the brand new specification coming with Jakarta EE 12. We'll show both with a selection of NoSQL or SQL queries to learn how they work and how they support concepts like CRUD operations, the Repository pattern, pagination or sorting. What types of databese they support best, and how they can help improve your data applications into a vendor-neutral future.

Avatar for Werner Keil

Werner Keil

January 15, 2026
Tweet

More Decks by Werner Keil

Other Decks in Programming

Transcript

  1. Standardized Data Access for Jakarta EE COPYRIGHT (C) 2024, ECLIPSE

    FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) Werner Keil January 15, 2026 Jakarta Data and NoSQL
  2. 2 • Consultant – Coach • Open-Source Activist • Software

    Architect • Husband, Father • Author, Speaker • Maintenance Lead – JSR 354, 385 • Jakarta EE Specification Committee Member Werner‘s Bio [www.linkedin.com/in/catmedia] COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  3. COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED

    UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) What are NoSQL Databases? COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  4. NoSQL 01 Database 02 Doesn't use (semi)structure 03 No transactions

    04 BASE Different types 05 COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  5. COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED

    UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) Types of NoSQL Databases COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  6. Key-Value stores AmazonS3 Apollo Ares Aphrodite Sun War Love Beauty

    AmazonDynamo Hazelcast Redis COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  7. Column-Oriented Apollo Aphrodite Ares Kratos Duty Duty Duty Dead Gods

    Love, happy Sun War 13 Color weapon Sword Row-key Columns HBase Scylla SimpleDB Cassandra DynamoDB Clouddata COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  8. Document stores { "name":"Diana", "duty":[ "Hunt", "Moon", "Nature" ], "siblings":{

    "Apollo":"brother" } } ApacheCouchDB MongoDB Couchbase
  9. Graph databases Apollo Ares Kratos was killed by was killed

    by killed killed Neo4j InfoGrid Sones HyperGraphDB
  10. Multi-Model 01 02 03 04 OrientDB (graph, document) Couchbase (key

    value, document) Elasticsearch (document, graph) ArangoDB (document, graph, key-value)
  11. COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED

    UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) SQL vs NoSQL COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  12. SQL vs NoSQL SQL KEY-VALUE COLUMN DOCUMENTS GRAPH Table Bucket

    Column family Collection Row Key/value pair Column Documents Vertex Column Key/value pair Key/value pair Vertex and Edge property Relationship Link Edge
  13. BASE vs ACID • Basically Available • Soft state •

    Eventual consistency • Atomicity • Consistency • Isolation • Durability
  14. CAP

  15. Relational Application NoSQL Application Logic Tier Logic Tier DAO DAO

    JPA JPA JPA JPA JDBC JDBC JDBC JDBC Data Tier API API API Data Tier
  16. JPA problem for NoSQL 01 02 03 04 05 06

    Saves Async Async Callback Time to Live (TTL) Consistency Level SQL based Diversity in NoSQL
  17. COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED

    UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) Jakarta Data 5 COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  18. Jakarta Data relational database business logic repository interface repository interface

    Jakarta Data Provider NoSQL database Jakarta Data / Jakarta NoSQL Provider JPA or JDBC
  19. • DataRepository doesn’t come with any built-in methods. To further

    simplify… @Inject Products products; … products.save(new Product(1, "$25 gift card", 25.0f)); List<Product> found = products.findByPriceLessThan(100.0f); @Repository public interface Products extends DataRepository<Product, Long> { List<Product> findByPriceLessThan(float maxPrice); void save(Product product); ... } public record Product( long id, String name, float price ); entity class key type Basic Entity and Repository
  20. @Inject Products products; … products.save(new Product(1, "$25 gift card", 25.0f));

    List<Product> found = products.findByPriceLessThan(100.0f); @Repository public interface Products extends CrudRepository<Product, Long> { List<Product> findByPriceLessThan(float maxPrice); ... } public record Product( long id, String name, float price ); entity class key type save(E entity); saveAll(Iterable<E> entities); findAll(); findById(K id); existsById(K id); delete(E entity); deleteById(K id); ... Inherited via CrudRepository: Basic Entity and CRUD Repository
  21. Name-Pattern Repository Methods Compose your own save, findBy, deleteBy, countBy

    & more methods by following precise naming conventions with reserved keywords and entity property names within the method name. Product[] findByNameLikeAndPriceBetween(String namePattern, float minPrice, float maxPrice); find...By indicates a query returning results And keyword separates NameLike and PriceBetween conditions Name and Price are entity property names Like keyword is a type of condition, requires 1 parameter Between keyword is a type of condition, requires 2 parameters
  22. Repository with Queries Some queries are too complex to be

    defined within a method name. @Query gives you a way to supply a query written in: JPQL (for Jakarta Persistence-based providers) @Repository public interface Products extends CrudRepository<Product, Long> { @Query("UPDATE Product o SET o.price = o.price - o.price * ?1") int discountAll(float discountRate); }
  23. If you prefer to use named parameters, you can do

    that with @Param, @Repository public interface Products extends CrudRepository<Product, Long> { @Query("UPDATE Product o SET o.price = o.price - o.price * :rate") int discountAll(@Param("rate") float discountRate); } Named Parameters
  24. Sorting Results Reserved keywords OrderBy, Asc, and Desc enable sorting

    of results. Product[] findByNameLikeAndPriceBetweenOrderByPriceDescNameAsc(String namePattern, float minPrice, float maxPrice); OrderBy keyword indicates the start of the sorting criteria Asc keyword indicates ascending sort Desc keyword indicates descending sort
  25. Sorting Results – better ways @OrderBy(value = "price", descending =

    true) @OrderBy("name") Product[] findByNameLikeAndPriceBetween(String namePattern, float minPrice, float maxPrice); Method names can get a bit lengthy, so there is also @OrderBy annotation for sorting criteria that is known in advance Sort parameters for dynamic sorting Product[] findByNameLikeAndPriceBetween(String namePattern, float minPrice, float maxPrice, Sort...); found = products.findByNameLikeAndPriceBetween(namePattern, 10.00f, 20.00f, Sort.desc("price"), Sort.asc("name"));
  26. Without Method Name Magic? @Filter(by = "price", op = Compare.Between)

    @Filter(by = "name", fn = Function.IgnoreCase, op = Compare.Contains) @OrderBy("price") Product[] inPriceRange(float min, float max, String namePattern); @Filter(by = "name") @Update(attr = "price", op = Operation.Multiply) boolean inflatePrice(String productName, float rate); @Delete @Filter(by = "reviews", op = Compare.Empty) int removeUnreviewed(); It could be possible to define queries entirely with annotations. • This idea was deferred to post v1.0, but Open Liberty has it working in a prototype: Javadoc: https://ibm.biz/JakartaData
  27. Limiting the Number of Results @OrderBy("price") Product[] findFirst10ByNameLike(String namePattern); Sometimes

    you don’t want to read the entire matching dataset and only care about the first several results. First keyword indicates the start of the sorting criteria 10 numeric value optionally indicates how many. When absent, only the very first result is returned. Another way: @OrderBy("price") Product[] findByNameLike(String namePattern, Limit limit); found = products.findByNameLike(namePattern, Limit.of(10));
  28. Offset Pagination @OrderBy("price") @OrderBy("name") Page<Product> findByNameLikeAndPriceBetween(String namePattern, float minPrice, float

    maxPrice, Pageable pagination); For large datasets, you can read data in pages, defined by the Pageable parameter, Offset pagination is convenient to users jumping multiple pages ahead or behind. But it’s inefficient in making the database fetch unwanted results, and if data is modified, some results might be missed or duplicated between pages! for (Pageable p = Pageable.ofSize(50); p != null; ) { Page<product> page = products.findByNameLikeAndPriceBetween(pattern, 40.0f, 60.0f, p); ... p = page.nextPageable(); }
  29. Keyset Pagination Reduces scenarios where results are missed or duplicated

    across pages. • Entity properties that serve as the sort criteria must not be modified. Gives the Pageable awareness of cursor position from a prior page. • Jakarta Data provider automatically adds conditions to the query making the previous cursor the starting point for the next page. Can be more efficient because it does not require fetching and skipping large numbers of results. Unwanted results never match to begin with!
  30. Keyset Pagination Examples @OrderBy("lastName") @OrderBy("id") KeysetAwarePage<Employee> findByHoursWorkedGreaterThanEqual(int minHours, Pageable pagination);

    Traversing all results, Or relative to a specific position, for (Pageable p = Pageable.ofSize(100); p != null; ) { KeysetAwarePage<Employee> page = employees.findByHoursWorkedGreaterThanEqual(1500, p); ... p = page.nextPageable(); } Pageable p = Pageable.ofSize(100).afterKeyset(employee.lastName, employee.id); page = employees.findByHoursWorkedGreaterThanEqual(1500, p); Order of keyset keys matches the order of sort criteria
  31. Keyset Pagination – How it Works @OrderBy("lastName") @OrderBy("firstName") @OrderBy("id") KeysetAwarePage<Employee>

    findByHoursWorkedGreaterThanEqual(int minHours, Pageable pagination); Let’s visualize what this could look like if transformed to JPQL: SELECT o FROM Employee o WHERE (o.hoursWorked >= ?1) AND ( (o.lastName > ?2) OR (o.lastName = ?2 AND o.firstName > ?3) OR (o.lastName = ?2 AND o.firstName = ?3 AND o.id > ?4) ) pagination.getKeysetCursor() provides the values for ?2, ?3, ?4
  32. COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED

    UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) Jakarta NoSQL 5 COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  33. BaseDocument baseDocument = new BaseDocument(); baseDocument.addAttribute(name, value); Document document =

    new Document(); document.append(name, value); JsonObject jsonObject = JsonObject.create(); jsonObject.put(name, value); ODocument document = new ODocument(“collection”); document.field(name, value); Motivation
  34. Make NoSQL easier @Inject Template template; … template.insert(book); List<Book> books

    = template.select(Book.class) .where("title").eq("Effective Java").list();
  35. Entity @Entity public class Person{ @Id private String id; @Column

    private String name; @Column private String city; } @Entity public record Book(@Id String id, @Column("title") String title, @Column("edition") int edition){}
  36. Entity @Entity public class Person{ @Id private String id; @Column

    private String name; @Column private String city; } key value key key key value value value Column Family Graph Document Key Value
  37. Annotated Entities 01 02 03 Mapped Superclass Entity Column @Entity("god")

    public class God { @Column private String name; @Column private long age; @Column private Set<String> powers; }
  38. Template @Inject Template template; ... Car ferrari = template.insert(ferrari); Optional<Car>

    car = template.find(Car.class, 1L); List<Car> cars = template.select(Car.class).where("city").eq("Rome").result(); template.delete(Car.class).where("id").eq(1L).execute(); Optional<Car> result = template.singleResult("select * from Car where id = 1");
  39. Repository with Queries @Repository interface PersonRepository extends CrudRepository<Person, Long> {

    @Query("select * from Person") Optional<Person> findByQuery(); @Query("select * from Person where id = @id") Optional<Person> findByQuery(@Param("id") String id); }
  40. @Entity("god") public class God { @Column private String name; @UDT("weapon")

    @Column private Weapon weapon; } @Repository interface GodRepository extends CassandraRepository<God, String> { @CQL("select * from God where name = ?") List<God> findByName(String name); } Custom Annotations
  41. COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED

    UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) Links and References 5 COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  42. ▪Specifications ▪Jakarta NoSQL: https://jakarta.ee/specifications/nosql/ ▪Jakarta Data: https://jakarta.ee/specifications/data/ ▪NoSQL Endgame repository

    ▪https://github.com/JNOSQL/nosql-endgame ▪JNoSQL Project page ▪http://jnosql.org ▪JAVAPRO Special Edition https://javapro.io/2025/11/30/05-2025-java-25-part-2-special-edition/ Links
  43. COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED

    UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0) Q & A 5 COPYRIGHT (C) 2024, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)
  44. THANK YOU! COPYRIGHT (C) 2024, ECLIPSE FOUNDATION | MADE AVAILABLE

    UNDER THE ECLIPSE PUBLIC LICENSE 2.0 (EPL-2.0) 28 To receive exclusive access to detailed industry research findings, join the Jakarta EE Working Group: Join Today Learn More: Connect: jakarta.ee @Jakarta.EE