Skip to content
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

add cache modes and timeout to @NamedQuery, @NamedNativeQuery #662

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
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