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
3 changes: 1 addition & 2 deletions api/src/main/java/jakarta/persistence/QueryFlushMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@
* @see Query#setQueryFlushMode(QueryFlushMode)
* @see NamedQuery#flush
* @see NamedNativeQuery#flush
* @see jakarta.persistence.query.ReadQueryOptions#flush
* @see jakarta.persistence.query.WriteQueryOptions#flush
* @see jakarta.persistence.query.StaticQueryOptions#flush
* @see FlushModeType
*
* @author Gavin King
Expand Down
6 changes: 2 additions & 4 deletions api/src/main/java/jakarta/persistence/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public sealed interface Reference
/**
* A map keyed by hint name of all hints specified via
* {@link NamedQuery#hints}, {@link NamedNativeQuery#hints},
* {@link jakarta.persistence.query.ReadQueryOptions#hints}, or
* {@link jakarta.persistence.query.WriteQueryOptions#hints}.
* {@link jakarta.persistence.query.StaticQueryOptions#hints}, or
* <p>
* Any attempted mutation of the returned map results in an
* {@link UnsupportedOperationException}.
Expand Down Expand Up @@ -113,8 +112,7 @@ public sealed interface Reference
* {@code null} if no timeout was specified.
*
* @see Query#setTimeout(Timeout)
* @see jakarta.persistence.query.ReadQueryOptions#timeout
* @see jakarta.persistence.query.WriteQueryOptions#timeout
* @see jakarta.persistence.query.StaticQueryOptions#timeout
* @since 4.0
*/
Timeout getTimeout();
Expand Down
13 changes: 6 additions & 7 deletions api/src/main/java/jakarta/persistence/TypedQueryReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

package jakarta.persistence;

import java.util.List;
import java.util.Map;
import jakarta.persistence.query.StaticQueryOptions;

/**
* A reference to a typed named query declared via the
Expand Down Expand Up @@ -110,7 +109,7 @@ public non-sealed interface TypedQueryReference<R> extends Reference {
* {@link EntityHandler} should be used.
*
* @see TypedQuery#setCacheRetrieveMode
* @see jakarta.persistence.query.ReadQueryOptions#cacheRetrieveMode
* @see StaticQueryOptions#cacheRetrieveMode
* @since 4.0
*/
CacheRetrieveMode getCacheRetrieveMode();
Expand All @@ -121,7 +120,7 @@ public non-sealed interface TypedQueryReference<R> extends Reference {
* {@link EntityHandler} should be used.
*
* @see TypedQuery#setCacheStoreMode
* @see jakarta.persistence.query.ReadQueryOptions#cacheStoreMode
* @see StaticQueryOptions#cacheStoreMode
* @since 4.0
*/
CacheStoreMode getCacheStoreMode();
Expand All @@ -133,7 +132,7 @@ public non-sealed interface TypedQueryReference<R> extends Reference {
*
* @see TypedQuery#setLockMode
* @see NamedQuery#lockMode
* @see jakarta.persistence.query.ReadQueryOptions#lockMode
* @see StaticQueryOptions#lockMode
* @since 4.0
*/
LockModeType getLockMode();
Expand All @@ -145,7 +144,7 @@ public non-sealed interface TypedQueryReference<R> extends Reference {
*
* @see TypedQuery#setLockScope
* @see NamedQuery#lockScope
* @see jakarta.persistence.query.ReadQueryOptions#lockScope
* @see StaticQueryOptions#lockScope
* @since 4.0
*/
PessimisticLockScope getPessimisticLockScope();
Expand All @@ -156,7 +155,7 @@ public non-sealed interface TypedQueryReference<R> extends Reference {
* specified.
*
* @see NamedQuery#entityGraph
* @see jakarta.persistence.query.ReadQueryOptions#entityGraph
* @see StaticQueryOptions#entityGraph
* @since 4.0
*/
String getEntityGraphName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* interface Library {
*
* @StaticNativeQuery("select * from books where title like ?")
* @ReadQueryOptions(cacheStoreMode = CacheStoreMode.BYPASS)
* @StaticQueryOptions(cacheStoreMode = CacheStoreMode.BYPASS)
* List<Book> findBooksByTitle(String title);
*
* @StaticNativeQuery("select * from books where isbn = ?")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* interface Library {
*
* @StaticQuery("from Book where title like :title")
* @ReadQueryOptions(cacheStoreMode = CacheStoreMode.BYPASS)
* @StaticQueryOptions(cacheStoreMode = CacheStoreMode.BYPASS)
* List<Book> findBooksByTitle(String title);
*
* @StaticQuery("from Book where isbn = :isbn")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,36 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* <p>Configures options that affect the execution of a
* database read operation. This annotation may be applied
* to:
* <p>Configures options that affect the execution of a query.
* This annotation may be applied to:
* <ul>
* <li>a method with a {@link StaticQuery} or Jakarta Data
* {@code jakarta.data.repository.Query} annotation
* whose {@code value} member specifies a {@code SELECT}
* statement,
* <li>a method with a {@link StaticNativeQuery} annotation
* whose {@code value} member specifies a SQL operation
* which returns a result set, or
* {@code jakarta.data.repository.Query} annotation,
* <li>a method with a {@link StaticNativeQuery} annotation,
* <li>a Jakarta Data repository method annotated
* {@code jakarta.data.repository.Delete} that uses the
* parameter-based automatic query pattern,
* or
* <li>a Jakarta Data repository method annotated
* {@code jakarta.data.repository.Find}.
* </ul>
*
* <p>This annotation must be respected by an implementation
* of Jakarta Data backed by Jakarta Persistence.
*
* @see WriteQueryOptions
*
* @since 4.0
*/
@Target(METHOD)
@Retention(RUNTIME)
public @interface ReadQueryOptions {
public @interface StaticQueryOptions {
/**
* The {@linkplain CacheStoreMode cache store mode} to use.
* The presence of this annotation overrides the default
* cache store mode of the persistence context.
* <p>
* This option applies when the query is a JPQL {@code select}
* query or a native query that returns a result set.
*
* @see jakarta.persistence.TypedQuery#setCacheStoreMode
*/
CacheStoreMode cacheStoreMode() default CacheStoreMode.USE;
Expand All @@ -67,6 +68,10 @@
* The {@linkplain CacheRetrieveMode cache retrieve mode}
* to use. The presence of this annotation overrides the
* default cache retrieve mode of the persistence context.
* <p>
* This option applies when the query is a JPQL {@code select}
* query or a native query that returns a result set.
*
* @see jakarta.persistence.TypedQuery#setCacheRetrieveMode
*/
CacheRetrieveMode cacheRetrieveMode() default CacheRetrieveMode.USE;
Expand All @@ -93,13 +98,20 @@
* <p> If a lock mode is explicitly specified for a
* {@linkplain StaticNativeQuery native query}, the behavior
* is undefined and unportable between persistence providers.
* <p>
* This option applies when the query is a JPQL {@code select}
* query or a native query that returns a result set.
*
* @see jakarta.persistence.TypedQuery#setLockMode
*/
LockModeType lockMode() default LockModeType.NONE;

/**
* The pessimistic lock scope to use in query execution if a
* pessimistic lock mode is specified via {@link #lockMode}.
* <p>
* This option applies when the query is a JPQL {@code select}
* query or a native query that returns a result set.
*/
PessimisticLockScope lockScope() default PessimisticLockScope.NORMAL;

Expand All @@ -112,6 +124,9 @@
* entity type, the behavior is undefined. The entity graph
* is interpreted as a load graph. The entity graph specified
* here may be overridden by calling {@code setEntityGraph()}.
* <p>
* This option applies when the query is a JPQL {@code select}.
*
*
* @see jakarta.persistence.NamedEntityGraph#name
*/
Expand All @@ -121,7 +136,6 @@
* The {@linkplain QueryFlushMode query flush mode} to use when
* executing the query.
* @see Query#setQueryFlushMode(QueryFlushMode)
* @since 4.0
*/
QueryFlushMode flush() default QueryFlushMode.DEFAULT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class StaticStatementReference
/**
* Intended for use in code generated by an annotation processor.
* This constructor overload is adapted to the case where the
* program element is annotated with {@link WriteQueryOptions}.
* program element is annotated with {@link StaticQueryOptions}.
*
* @param queryName The name of the query, the concatenation of
* the unqualified name of the annotated type,
Expand All @@ -62,8 +62,8 @@ public class StaticStatementReference
* annotated member
* @param arguments The arguments supplied to the parameters
* at runtime
* @param timeout See {@link WriteQueryOptions#timeout}
* @param hints See {@link WriteQueryOptions#hints}
* @param timeout See {@link StaticQueryOptions#timeout}
* @param hints See {@link StaticQueryOptions#hints}
*/
public StaticStatementReference(
String queryName,
Expand All @@ -87,7 +87,7 @@ public StaticStatementReference(
/**
* Intended for use in code generated by an annotation processor.
* This constructor overload is adapted to the case where the
* program element is not annotated with {@link WriteQueryOptions}.
* program element is not annotated with {@link StaticQueryOptions}.
*
* @param queryName The name of the query, the concatenation of
* the unqualified name of the annotated type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class StaticTypedQueryReference<R>
/**
* Intended for use in code generated by an annotation processor.
* This constructor overload is adapted to the case where the
* program element is annotated with {@link ReadQueryOptions}.
* program element is annotated with {@link StaticQueryOptions}.
*
* @param queryName The name of the query, the concatenation of
* the unqualified name of the annotated type,
Expand All @@ -77,13 +77,13 @@ public class StaticTypedQueryReference<R>
* annotated member
* @param arguments The arguments supplied to the parameters
* at runtime
* @param cacheRetrieveMode See {@link ReadQueryOptions#cacheRetrieveMode}
* @param cacheStoreMode See {@link ReadQueryOptions#cacheStoreMode}
* @param lockMode See {@link ReadQueryOptions#lockMode}
* @param lockScope See {@link ReadQueryOptions#lockScope}
* @param timeout See {@link ReadQueryOptions#timeout}
* @param entityGraphName See {@link ReadQueryOptions#entityGraph}
* @param hints See {@link ReadQueryOptions#hints}
* @param cacheRetrieveMode See {@link StaticQueryOptions#cacheRetrieveMode}
* @param cacheStoreMode See {@link StaticQueryOptions#cacheStoreMode}
* @param lockMode See {@link StaticQueryOptions#lockMode}
* @param lockScope See {@link StaticQueryOptions#lockScope}
* @param timeout See {@link StaticQueryOptions#timeout}
* @param entityGraphName See {@link StaticQueryOptions#entityGraph}
* @param hints See {@link StaticQueryOptions#hints}
*/
public StaticTypedQueryReference(
String queryName,
Expand Down Expand Up @@ -119,7 +119,7 @@ public StaticTypedQueryReference(
/**
* Intended for use in code generated by an annotation processor.
* This constructor overload is adapted to the case where the
* program element is not annotated with {@link ReadQueryOptions}.
* program element is not annotated with {@link StaticQueryOptions}.
*
* @param queryName The name of the query, the concatenation of
* the unqualified name of the annotated type,
Expand Down
76 changes: 0 additions & 76 deletions api/src/main/java/jakarta/persistence/query/WriteQueryOptions.java

This file was deleted.

2 changes: 1 addition & 1 deletion spec/src/main/asciidoc/appA-revision-history.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This appendix lists the significant changes that have been made during the devel

Added `EntityAgent` and `EntityHandler`

Added `@StaticQuery`, `@StaticNativeQuery`, `@ReadQueryOptions`, `@WriteQueryOptions` and `StaticStatementReference` for declaring static queries at the method level, along with additional members of `TypedQueryReference`
Added `@StaticQuery`, `@StaticNativeQuery`, `@StaticQueryOptions`, and `StaticStatementReference` for declaring static queries at the method level, along with additional members of `TypedQueryReference`

Added a new API for programmatic SQL result set mappings

Expand Down
10 changes: 2 additions & 8 deletions spec/src/main/asciidoc/appF-static-queries.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@ include::../../../../api/src/main/java/jakarta/persistence/query/StaticQuery.jav
include::../../../../api/src/main/java/jakarta/persistence/query/StaticNativeQuery.java[lines=18..-1]
----

=== `ReadQueryOptions`
=== `StaticQueryOptions`
[source,java]
----
include::../../../../api/src/main/java/jakarta/persistence/query/ReadQueryOptions.java[lines=18..-1]
----

=== `WriteQueryOptions`
[source,java]
----
include::../../../../api/src/main/java/jakarta/persistence/query/WriteQueryOptions.java[lines=18..-1]
include::../../../../api/src/main/java/jakarta/persistence/query/StaticQueryOptions.java[lines=18..-1]
----

=== `StaticStatementReference`
Expand Down
4 changes: 2 additions & 2 deletions spec/src/main/asciidoc/ch03-entity-operations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3243,7 +3243,7 @@ Execution of a JPQL query obtains a lock on queried records if the
application requests such a lock by:

- calling `setLockMode()`, or
- specifying the `lockMode` member of the `@ReadQueryOptions` or
- specifying the `lockMode` member of the `@StaticQueryOptions` or
`@NamedQuery` annotation.

If a query is executed when no transaction is active, then the specified
Expand All @@ -3260,7 +3260,7 @@ object.] The scope of a pessimistic lock, as defined above in
<<a2066>>, is controlled by:

- calling `setLockScope()`, or
- specifying the `lockScope` member of the `@ReadQueryOptions` or
- specifying the `lockScope` member of the `@StaticQueryOptions` or
`@NamedQuery` annotation.

If the lock mode type is `PESSIMISTIC_READ`,
Expand Down
Loading