Skip to content

Commit

Permalink
add cache modes and timeout to @NamedQuery, @NamedNativeQuery
Browse files Browse the repository at this point in the history
see issue jakartaee#473

Signed-off-by: Gavin King <[email protected]>
  • Loading branch information
gavinking committed Sep 20, 2024
1 parent 1aac75c commit 6ef3994
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 7 deletions.
37 changes: 31 additions & 6 deletions api/src/main/java/jakarta/persistence/NamedNativeQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

// Contributors:
// Gavin King - 4.0
// Gavin King - 3.2
// Petros Splinakis - 2.2
// Linda DeMichiel - 2.1
Expand Down Expand Up @@ -95,12 +96,6 @@
*/
String query();

/**
* Query properties and hints.
* (May include vendor-specific query hints.)
*/
QueryHint[] hints() default {};

/**
* The class of each query result. If a {@link #resultSetMapping
* result set mapping} is specified, the specified result class
Expand Down Expand Up @@ -145,4 +140,34 @@
* @since 3.2
*/
ColumnResult[] columns() default {};

/**
* (Optional) The {@linkplain CacheStoreMode cache store mode}
* to use in query execution.
* @since 4.0
* @see Query#setCacheStoreMode
*/
CacheStoreMode cacheStoreMode() default CacheStoreMode.USE;

/**
* (Optional) The {@linkplain CacheRetrieveMode cache retrieve mode}
* to use in query execution.
* @since 4.0
* @see Query#setCacheRetrieveMode
*/
CacheRetrieveMode cacheRetrieveMode() default CacheRetrieveMode.USE;

/**
* (Optional) A query timeout in milliseconds. By default,
* there is no timeout.
* @since 4.0
* @see Query#setTimeout
*/
int timeout() default -1;

/**
* Query properties and hints.
* (May include vendor-specific query hints.)
*/
QueryHint[] hints() default {};
}
28 changes: 27 additions & 1 deletion api/src/main/java/jakarta/persistence/NamedQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

// Contributors:
// Gavin King - 4.0
// Gavin King - 3.2
// Petros Splinakis - 2.2
// Linda DeMichiel - 2.1
Expand Down Expand Up @@ -86,9 +87,34 @@
* is specified, the query must be executed in a transaction
* and the persistence context joined to the transaction.
* @since 2.0
* @see Query#setLockMode
*/
LockModeType lockMode() default LockModeType.NONE;


/**
* (Optional) The {@linkplain CacheStoreMode cache store mode}
* to use in query execution.
* @since 4.0
* @see Query#setCacheStoreMode
*/
CacheStoreMode cacheStoreMode() default CacheStoreMode.USE;

/**
* (Optional) The {@linkplain CacheRetrieveMode cache retrieve mode}
* to use in query execution.
* @since 4.0
* @see Query#setCacheRetrieveMode
*/
CacheRetrieveMode cacheRetrieveMode() default CacheRetrieveMode.USE;

/**
* (Optional) A query timeout in milliseconds. By default,
* there is no timeout.
* @since 4.0
* @see Query#setTimeout
*/
int timeout() default -1;

/**
* (Optional) Query properties and hints. May include
* vendor-specific query hints.
Expand Down

0 comments on commit 6ef3994

Please sign in to comment.