Repository navigation
Split JakartaStatement from JakartaQuery, &c. #1229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gavinking
merged 7 commits into
jakartaee:main
from
gavinking:split-static-query-annotations
Nov 23, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
92c2aad
Split JakartaStatement from JakartaQuery, &c.
gavinking 6a4ebb9
fix spec for name of static queries
gavinking 73f9251
Update api/src/main/java/jakarta/persistence/StatementReference.java
gavinking dac9759
queryName -> statementName
gavinking f6f5e76
one query annotation at most
gavinking a7a8c5e
TCK tests for static query annotations
gavinking bfaf50a
TCK tests for static query annotations
gavinking File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
api/src/main/java/jakarta/persistence/query/JakartaStatement.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /* | ||
| * Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License v. 2.0 which is available at | ||
| * http://www.eclipse.org/legal/epl-2.0, | ||
| * or the Eclipse Distribution License v. 1.0 which is available at | ||
| * http://www.eclipse.org/org/documents/edl-v10.php. | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
| */ | ||
|
|
||
| // Contributors: | ||
| // Gavin King - 4.0 | ||
|
|
||
| package jakarta.persistence.query; | ||
|
|
||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| import static java.lang.annotation.ElementType.METHOD; | ||
| import static java.lang.annotation.RetentionPolicy.RUNTIME; | ||
|
|
||
| /** | ||
| * Specifies an {@code UPDATE} or {@code DELETE} statement expressed in | ||
| * the Jakarta Persistence Query Language. A {@code SELECT} query must be | ||
| * declared using {@link JakartaQuery}. | ||
| * This annotation may be applied to: | ||
| * <ul> | ||
| * <li>any method of any class or interface belonging to the persistence | ||
| * unit, or | ||
| * <li>a query method of a Jakarta Data repository with an implementation | ||
| * backed by Jakarta Persistence. | ||
| * </ul> | ||
| * <p> The return type of the method must be {@code void}, {@code int}, | ||
| * or {@code long}. The parameter types of the method must agree with the | ||
| * types of the statement parameters. An implementation of Jakarta | ||
| * Persistence or of Jakarta Data may be able to determine if such | ||
| * agreement exists at compilation time or when the persistence unit is | ||
| * initialized, but this is not required. | ||
| * | ||
| * <p> | ||
| * {@snippet : | ||
| * interface Library { | ||
| * @JakartaStatement("delete from Trash") | ||
| * @StatementOptions(timeout = 30_000) | ||
| * int emptyTrash(); | ||
| * } | ||
| * } | ||
| * | ||
| * <p> A method parameter type <em>agrees</em> with a statement parameter | ||
| * type if it is a type that could be assigned to the corresponding | ||
| * statement parameter by passing an instance of the type to | ||
| * {@code setParameter()}. In making this determination, method parameters | ||
| * are correlated with statement parameters by position or by name, | ||
| * depending on whether the statement uses positional or named parameters. | ||
| * | ||
| * <p> The parameter types of the annotated method must be basic types. | ||
| * If this annotation occurs on a generic method, on a method with a | ||
| * parameter type which is not a basic type, or on a method with a | ||
| * parameter type involving a type variable, the behavior is undefined. | ||
| * | ||
| * <p> Any implementation of Jakarta Data backed by Jakarta Persistence | ||
| * must support the use of this annotation as a Jakarta Data query | ||
| * annotation. Thus, a repository method annotated {@code @JakartaStatement} | ||
| * is treated by the Jakarta Data provider as a query method, and an | ||
| * implementation of the method is supplied by the Jakarta Data provider. | ||
| * | ||
| * <p> When this annotation is applied to a method of a class or interface | ||
| * belonging to the persistence unit, a reference to a statement declared | ||
| * using this annotation may be obtained from the static metamodel class | ||
| * of the annotated class or interface. | ||
| * {@snippet : | ||
| * int deleted = | ||
| * em.createStatement(Library_.emptyTrash()) | ||
| * .execute(); | ||
| * } | ||
| * | ||
| * <p> In addition, the statement is treated as a named statement, where | ||
| * the statement name agrees with the convention for Javadoc links, that | ||
| * is: the concatenation of the fully qualified name of the type, with | ||
| * the string {@code #}, the name of the annotated member, and the raw | ||
| * types of the method parameters, enclosed in parentheses and separated | ||
| * by commas, for example, {@code "org.example.Library#emptyTrash()"}. | ||
| * | ||
| * <p> The persistence provider must treat the annotation | ||
| * {@code jakarta.data.repository.Query} as a synonym for this annotation | ||
| * when it specifies an {@code UPDATE} or {@code DELETE} statement. A | ||
| * method must not be annotated with more than one of {@code JakartaQuery}, | ||
| * {@code JakartaStatement}, {@code NatveQuery}, {@code NativeStatement}, | ||
| * and {@code Query}. | ||
| * | ||
| * @see JakartaQuery | ||
| * @see StatementOptions | ||
| * | ||
| * @since 4.0 | ||
| */ | ||
| @Target(METHOD) | ||
| @Retention(RUNTIME) | ||
| public @interface JakartaStatement { | ||
| /** | ||
| * The statement string in the Jakarta Persistence Query Language. | ||
| */ | ||
| String value(); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.