From 1cc4d0f262fbaa77046fbb99d22323f21eedba19 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 19 Aug 2023 13:33:18 +0200 Subject: [PATCH] add Query.setTimeout() see #383 --- api/src/main/java/jakarta/persistence/Query.java | 14 ++++++++++++++ .../jakarta/persistence/StoredProcedureQuery.java | 8 ++++++++ .../main/java/jakarta/persistence/TypedQuery.java | 7 +++++++ 3 files changed, 29 insertions(+) diff --git a/api/src/main/java/jakarta/persistence/Query.java b/api/src/main/java/jakarta/persistence/Query.java index 3748e745..317ee80b 100644 --- a/api/src/main/java/jakarta/persistence/Query.java +++ b/api/src/main/java/jakarta/persistence/Query.java @@ -546,6 +546,20 @@ Query setParameter(int position, Date value, */ CacheStoreMode getCacheStoreMode(); + /** + * Set the query timeout. + * @param timeout the timeout, or null to indicate no timeout + * @return the same query instance + * @since 3.2 + */ + Query setTimeout(Integer timeout); + + /** + * The query timeout. + * @since 3.2 + */ + Integer getTimeout(); + /** * Return an object of the specified type to allow access to * the provider-specific API. If the provider's query diff --git a/api/src/main/java/jakarta/persistence/StoredProcedureQuery.java b/api/src/main/java/jakarta/persistence/StoredProcedureQuery.java index 7c814d8d..8a99851b 100644 --- a/api/src/main/java/jakarta/persistence/StoredProcedureQuery.java +++ b/api/src/main/java/jakarta/persistence/StoredProcedureQuery.java @@ -281,6 +281,14 @@ StoredProcedureQuery setParameter(int position, */ StoredProcedureQuery setCacheStoreMode(CacheStoreMode cacheStoreMode); + /** + * Set the query timeout. + * @param timeout the timeout, or null to indicate no timeout + * @return the same query instance + * @since 3.2 + */ + StoredProcedureQuery setTimeout(Integer timeout); + /** * Register a positional parameter. * All parameters must be registered. diff --git a/api/src/main/java/jakarta/persistence/TypedQuery.java b/api/src/main/java/jakarta/persistence/TypedQuery.java index 51bb93e2..6b15a0c6 100644 --- a/api/src/main/java/jakarta/persistence/TypedQuery.java +++ b/api/src/main/java/jakarta/persistence/TypedQuery.java @@ -336,4 +336,11 @@ TypedQuery setParameter(int position, Date value, */ TypedQuery setCacheStoreMode(CacheStoreMode cacheStoreMode); + /** + * Set the query timeout. + * @param timeout the timeout, or null to indicate no timeout + * @return the same query instance + * @since 3.2 + */ + TypedQuery setTimeout(Integer timeout); }