Skip to content

Integrate Jakarta Query Language into Jakarta NoSQL #199

@otaviojava

Description

@otaviojava

Introduce a new API in Jakarta NoSQL that allows executing string-based queries defined by the Jakarta Query specification.

This integration will support executing JPQL-like queries using Jakarta NoSQL’s Template API, mirroring the developer experience found in Jakarta Persistence.

🎯 Goals:

  • Provide support for Jakarta Query string-based queries.

  • Support the main query operations:

    • select via .result()
    • update via .executeUpdate()
    • delete via .executeDelete()
  • Enable a fluent interface via Template.query(String, Class<T>) returning a Query<T> instance.

  • Support both named (:param) and positional (?1) parameters via .bind() methods.

💡 Usage Example:

@Inject
Template template;

List<Word> results = template.query("from Word where term = 'java'", Word.class)
                             .result();

template.query("update Word set meaning = 'coffee' where term = 'java'", Word.class)
        .executeUpdate();

template.query("delete from Word where term = 'obsolete'", Word.class)
        .executeDelete();

With named and positional parameters:

template.query("from Word where term = :term", Word.class)
        .bind("term", "java")
        .result();

template.query("from Word where term = ?1", Word.class)
        .bind(1, "java")
        .result();

⚠️ Consistency Note:

Since NoSQL databases typically offer eventual consistency, the update() and delete() operations will return void to avoid giving the impression of guaranteed immediate persistence.

🧪 TCK Note:

This feature must include a Technology Compatibility Kit (TCK) covering:

  • Selection queries
  • Update queries
  • Deletion queries

✅ Checklist:

  • Extend Template with a new method: query(String query, Class<T> type)

  • Define the Query<T> interface with:

    • List<T> result()
    • void executeUpdate()
    • void executeDelete()
    • Query<T> bind(String name, Object value)
    • Query<T> bind(int position, Object value)
  • Implement internal logic to parse and map string queries to execution

  • Add TCK tests for:

    • select with both parameter types
    • update with both parameter types
    • delete with both parameter types
  • Update the Jakarta NoSQL specification with API details and examples

  • Provide user documentation with complete usage samples

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions