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); }