public class Product { @Id private String id; @Column private String name; @Column private String category; @Column private BigDecimal price; // Unannotated field: NOT persisted private String internalComment; } ⚠ Important In Jakarta NoSQL, persistable attributes should be explicitly annotated. Unannotated attributes are ignored.
Best-Fit Scenarios • • • • • Key Sessions Caching Shopping carts User preferences Simple state lookup Value @Inject KeyValueTemplate template; // Store value by key template.put(car); // Retrieve value by key Optional<Car> car = template.get(1L, Car.class); // Delete value by key template.delete(1L); Retrieves the complete value by key, rather than querying individual attributes or inner fields. Conceptual Serialization Car Object Driver Serialization Stored Value Complete object is stored as the value. Format depends on the driver/provider: Driver-dependent examples: • Java/native binary • Text / Plain string • JSON document • Provider-specific format Eclipse JNoSQL implementation API
Architecture • Organized around rows and column families • Individual pieces of information can be represented as columns • Designed for large distributed datasets • Data modeling is strongly influenced by the queries the application needs Row Key ├─ name ├─ city ├─ type └─ ... ColumnTemplate.java @Inject ColumnTemplate template; // Insert entity template.insert(car); // Lookup by primary key Optional<Car> car = template.find(Car.class, 1L); Architectural Considerations • Primary-key-oriented access: Built for scale and extreme write throughput. • Secondary indexes: Can enable additional access paths, but availability and performance depend heavily on the underlying database. • UDT / Structured types: Database-specific capability where supported, not a universal Jakarta NoSQL guarantee. // Fluent query delete template.delete(Car.class) .where("id").eq(1L) .execute(); ! Optimizes layout on disk by grouping related columns together for multi-node efficiency. Model for the queries you need Always design tables around access patterns first. Avoid relational join paradigms as cross-partition queries carry heavy performance penalties. Eclipse JNoSQL implementation API
ecosystem BEFORE Fragmented Query Models Capabilities defined independently across separate specifications with redundant and divergent syntax. JPQL JD-QL Jakarta Persistence Jakarta Data Jakarta NoSQL JNoSQL UNIFIED APPROACH Unified Query Standard Extracts the shared object-oriented query model into a single foundational specification. Jakarta Query Shared OO Foundation Key Advantages • Single learning curve across specifications • Consistent AST & type-safe metamodel • Seamless portability between persistence layers Common AST • Parser • Metamodel • Dialects
for relational persistence COMMON SUBSET EXTENDED RELATIONAL Jakarta Common Query Language Jakarta Persistence Query Language JCQL JPQL • Common query capabilities • Richer relational query semantics • Designed to be implementable across multiple datastore technologies • Relevant to Jakarta Persistence • May also be supported by Jakarta Data providers backed by relational persistence • Relevant to Jakarta Data and Jakarta NoSQL • Intentionally avoids relational-only assumptions LANGUAGE RELATIONSHIP JPQL Richer Relational Semantics Extends JCQL with relational features JCQL (Common Subset) Universal baseline across all datastore providers
typed projections Query API & Binding PARAMETERS List<Car> cars = template.query( "FROM Car WHERE type = :type" ).bind("type", CarType.SPORT).result(); Optional<Car> car = template.query( "FROM Car WHERE id = :id" ).bind("id", 42).singleResult(); • QUERY STRING Intuitive string-based query syntax Typed Projections PROJECTION @Projection public record TechCarView( String name, CarType type ) {} List<TechCarView> cars = template.typedQuery( "FROM Car WHERE type = 'SPORT'", TechCarView.class ).result(); • @PROJECTION ANNOTATION • PARAM BINDING Maps custom database shape directly to lightweight DTOs Safe named parameter injection • RECORD-BASED PROJECTION Leverages modern immutable Java Records for clean mapping • LIST RESULT • SINGLE RESULT Retrieve multi-record collections Safe Optional-based retrieval • TYPED QUERY RESULT Strongly-typed template queries without manual mapping