Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ List<Product> found = products.findAll(
);
----

== Jakarta Data Query Language (JDQL)
== Jakarta Common Query Language (JCQL)

Jakarta Data introduces the Jakarta Data Query Language (JDQL), a streamlined query language designed to specify the semantics of query methods within Jakarta Data repositories. Utilizing the `@Query` annotation, JDQL allows developers to define queries straightforwardly and robustly.
A query language for relational and non-relational data, Jakarta Common Query Language (JCQL), is defined by the Jakarta Query specification. Jakarta Data repository methods can be annotated `@Query` to indicate that the method runs a given JCQL query upon invocation of the method.

JDQL is conceptualized as a subset of the Jakarta Persistence Query Language (JPQL). It inherits its syntax and functionality while being specifically tailored to accommodate the broad spectrum of data storage technologies supported by Jakarta Data. This design approach ensures that JDQL remains compatible with JPQL yet simplifies its implementation across diverse data stores.
JCQL is conceptualized as a subset of the Jakarta Persistence Query Language (JPQL). It inherits its syntax and functionality while being specifically tailored to accommodate the broad spectrum of data storage technologies supported by Jakarta Data. This design approach ensures that JCQL remains compatible with JPQL yet simplifies its implementation across diverse data stores.

[source,java]
----
Expand All @@ -153,7 +153,7 @@ public interface BookRepository extends BasicRepository<Book, UUID> {
}
----

*JDQL* supports three primary types of statements, reflecting the core operations typically required for data manipulation and retrieval in applications:
*JCQL* supports three primary types of statements, reflecting the core operations typically required for data manipulation and retrieval in applications:

* *Select Statements*: Facilitate data retrieval from a data store, allowing for the specification of criteria to filter results.
* *Update Statements*: This option enables the modification of existing records in the data store based on specified criteria.
Expand Down
9 changes: 8 additions & 1 deletion api/src/main/java/jakarta/data/page/CursoredPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package jakarta.data.page;

import jakarta.data.repository.OrderBy;
import jakarta.data.repository.Query;
import jakarta.data.Order;
import jakarta.data.Sort;

Expand Down Expand Up @@ -109,9 +110,15 @@
*
* <h2>Cursor-based Pagination with {@code @Query}</h2>
*
* <p>The {@link Query} annotation from Jakarta Data and the similar
* {@code jakarta.persistence.StaticQuery} annotation from Jakarta Persistence
* allow the application to supply a Jakarta Common Query Language (JCQL) or
* Jakarta Persistence Query Language (JPQL) query for the repository method
* to perform.</p>
*
* <p>Cursor-based pagination involves generating and appending additional
* restrictions involving the key elements to the {@code WHERE} clause of the
* query. For this to be possible, a user-provided JDQL or JPQL query must end
* query. For this to be possible, a user-provided JCQL or JPQL query must end
* with a {@code WHERE} clause to which additional conditions may be
* appended. Cursor-pagination is not available for native SQL queries and
* some JPQL queries.</p>
Expand Down
5 changes: 3 additions & 2 deletions api/src/main/java/jakarta/data/repository/OrderBy.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
* <ul>
* <li>the <em>Query by Method Name</em> {@code OrderBy} keyword in its
* name,</li>
* <li>a {@link Query} or {@link jakarta.persistence.query.StaticQuery}
* <li>a {@link Query} or {@code jakarta.persistence.query.StaticQuery}
* annotation specifying a query with an {@code ORDER BY} clause, nor</li>
* <li>a {@link jakarta.persistence.query.StaticNativeQuery} annotation.</li>
* <li>a {@code jakarta.persistence.query.StaticNativeQuery} annotation.</li>
* </ul>
* <p>A Jakarta Data provider is permitted to reject such a repository
* method declaration at compile time or to implement the method to
Expand All @@ -85,6 +85,7 @@
* or a more specific subclass if the database is incapable of
* ordering with the requested sort criteria.</p>
*/
// TODO replace @code with @link to StaticQuery/StaticNativeQuery once Persistence 4.0 M1 is available
@Repeatable(OrderBy.List.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
Expand Down
23 changes: 12 additions & 11 deletions api/src/main/java/jakarta/data/repository/Query.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022,2025 Contributors to the Eclipse Foundation
* Copyright (c) 2022,2026 Contributors to the Eclipse Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,16 +30,17 @@

/**
* <p>Annotates a repository method as a query method, specifying a query
* written in Jakarta Data Query Language (JDQL) or in Jakarta Persistence
* Query Language (JPQL). A Jakarta Data provider is not required to support
* written in Jakarta Common Query Language (JCQL) or in Jakarta Persistence
* Query Language (JPQL). JCQL and JPQL are defined by the Jakarta Query
* specification. A Jakarta Data provider is not required to support
* the complete JPQL language, which targets relational data stores. However,
* a given provider might offer features of JPQL which go beyond the subset
* required by JDQL, or might even offer vendor-specific extensions to JDQL
* required by JCQL, or might even offer vendor-specific extensions to JCQL
* which target particular capabilities of the target data store technology.
* Such extensions come with no guarantee of portability between providers,
* nor between databases.</p>
*
* <p>The required {@link #value} member specifies the JDQL or JPQL query as
* <p>The required {@link #value} member specifies the JCQL or JPQL query as
* a string.</p>
*
* <p>For {@code select} statements, the return type of the query method must
Expand Down Expand Up @@ -72,14 +73,14 @@
* </li>
* </ul>
*
* <p>Compared to SQL, JDQL allows an abbreviated syntax for {@code select}
* <p>Compared to SQL, JCQL allows an abbreviated syntax for {@code select}
* statements:</p>
* <ul>
* <li>The {@code from} clause is optional in JDQL. When it is missing, the
* <li>The {@code from} clause is optional in JCQL. When it is missing, the
* queried entity is determined by the return type of the repository
* method, or, if the return type is not an entity type, by the primary
* entity type of the repository.</li>
* <li>The {@code select} clause is optional in both JDQL and JPQL. When it
* <li>The {@code select} clause is optional in both JCQL and JPQL. When it
* is missing, the query returns the queried entity.</li>
* </ul>
*
Expand Down Expand Up @@ -119,11 +120,11 @@
* @Repository
* public interface People extends CrudRepository<Person, Long> {
*
* // JDQL with positional parameters
* // JCQL with positional parameters
* @Query("where firstName = ?1 and lastName = ?2")
* List<Person> byName(String first, String last);
*
* // JDQL with a named parameter
* // JCQL with a named parameter
* @Query("where firstName || ' ' || lastName like :pattern")
* List<Person> byName(String pattern);
*
Expand Down Expand Up @@ -177,7 +178,7 @@

/**
* <p>Specifies the query executed by the annotated repository method,
* in JDQL or JPQL.</p>
* in JCQL or JPQL.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@njr-11 shall we use Jakarta Query here?

I mean, on this case it will run any of the languages of the query spec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Jakarta Query adds additional language levels, we might or might not be able to support them in Jakarta Data. We would want to assess each on a case by case basis.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh ok, good point.

*
* <p>If the annotated repository method accepts other forms of sorting
* (such as a parameter of type {@link Sort}), it is the responsibility of
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation
* Copyright (c) 2025,2026 Contributors to the Eclipse Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -53,7 +53,7 @@ static <N extends Number & Comparable<N>> NumericLiteral<N> of(N value) {
// Integer value, but there was no indication of this given that both
// convert to the same String. We could switch the output to include a
// suffix, such as 'I' at the end, but the downside of that would be not
// matching JDQL.
// matching JCQL.
/**
* <p>Returns a {@code String} representing the literal numeric value.</p>
*
Expand Down
9 changes: 5 additions & 4 deletions api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,11 @@
* Stream&lt;Person&gt; livingInCity(String address_city);
* </pre>
*
* <h2>JDQL query methods</h2>
* <h2>Methods annotated {@code @Query}</h2>
*
* <p>The {@link Query} annotation specifies that a method executes a query written
* in Jakarta Data Query Language (JDQL) or Jakarta Persistence Query Language (JPQL).
* <p>The {@link Query} annotation specifies that a method executes a query
* written in Jakarta Common Query Language (JCQL) or Jakarta Persistence
* Query Language (JPQL), which are defined by the Jakarta Query specification.
* A Jakarta Data provider is not required to support the complete JPQL language,
* which targets relational data stores.</p>
*
Expand Down Expand Up @@ -892,7 +893,7 @@
* a <em>special parameter</em> of type {@link Restriction}.</p>
*
* <p>Special parameters occur after parameters related to query conditions
* and JDQL query parameters. Special parameters enable limits, pagination,
* and JCQL query parameters. Special parameters enable limits, pagination,
* sorting, and restrictions to be determined at runtime.</p>
*
* <h3>Limits</h3>
Expand Down
101 changes: 0 additions & 101 deletions spec/src/antlr/JDQL.g4

This file was deleted.

Loading