Skip to content

Commit

Permalink
add EntityTransaction.setTimeout
Browse files Browse the repository at this point in the history
see #573
  • Loading branch information
gavinking committed Feb 26, 2024
1 parent a77d9b7 commit 92ef50d
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 6 deletions.
15 changes: 15 additions & 0 deletions api/src/main/java/jakarta/persistence/EntityTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

// Contributors:
// Gavin King - 3.2
// Linda DeMichiel - 2.1
// Linda DeMichiel - 2.0

Expand Down Expand Up @@ -71,4 +72,18 @@ public interface EntityTransaction {
* condition is encountered
*/
boolean isActive();

/**
* Set the transaction timeout, in seconds. This is a hint.
* @param timeout the timeout, in seconds, or null to indicate
* that the database server should set the timeout
* @since 3.2
*/
void setTimeout(Integer timeout);

/**
* The transaction timeout.
* @since 3.2
*/
Integer getTimeout();
}
7 changes: 5 additions & 2 deletions api/src/main/java/jakarta/persistence/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,11 @@ Query setParameter(int position, Date value,
CacheStoreMode getCacheStoreMode();

/**
* Set the query timeout.
* @param timeout the timeout, or null to indicate no timeout
* Set the query timeout, in milliseconds. This is a hint,
* and is an alternative to {@linkplain #setHint setting
* the hint} {@code jakarta.persistence.query.timeout}.
* @param timeout the timeout, in milliseconds, or null to
* indicate no timeout
* @return the same query instance
* @since 3.2
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,11 @@ StoredProcedureQuery setParameter(int position,
StoredProcedureQuery setCacheStoreMode(CacheStoreMode cacheStoreMode);

/**
* Set the query timeout.
* @param timeout the timeout, or null to indicate no timeout
* Set the query timeout, in milliseconds. This is a hint,
* and is an alternative to {@linkplain #setHint setting
* the hint} {@code jakarta.persistence.query.timeout}.
* @param timeout the timeout, in milliseconds, or null to
* indicate no timeout
* @return the same query instance
* @since 3.2
*/
Expand Down
7 changes: 5 additions & 2 deletions api/src/main/java/jakarta/persistence/TypedQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,11 @@ TypedQuery<X> setParameter(int position, Date value,
TypedQuery<X> setCacheStoreMode(CacheStoreMode cacheStoreMode);

/**
* Set the query timeout.
* @param timeout the timeout, or null to indicate no timeout
* Set the query timeout, in milliseconds. This is a hint,
* and is an alternative to {@linkplain #setHint setting
* the hint} {@code jakarta.persistence.query.timeout}.
* @param timeout the timeout, in milliseconds, or null to
* indicate no timeout
* @return the same query instance
* @since 3.2
*/
Expand Down
38 changes: 38 additions & 0 deletions spec/src/main/asciidoc/ch03-entity-operations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4907,6 +4907,23 @@ public interface Query {
*/
CacheStoreMode getCacheStoreMode();
/**
* Set the query timeout, in milliseconds. This is a hint,
* and is an alternative to {@linkplain #setHint setting
* the hint} {@code jakarta.persistence.query.timeout}.
* @param timeout the timeout, in milliseconds, 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
Expand Down Expand Up @@ -5249,6 +5266,16 @@ public interface TypedQuery<X> extends Query {
*/
TypedQuery<X> setCacheStoreMode(CacheStoreMode cacheStoreMode);
/**
* Set the query timeout, in milliseconds. This is a hint,
* and is an alternative to {@linkplain #setHint setting
* the hint} {@code jakarta.persistence.query.timeout}.
* @param timeout the timeout, in milliseconds, or null to
* indicate no timeout
* @return the same query instance
* @since 3.2
*/
TypedQuery<X> setTimeout(Integer timeout);
}
----

Expand Down Expand Up @@ -5690,6 +5717,17 @@ public interface StoredProcedureQuery extends Query {
*/
StoredProcedureQuery setCacheStoreMode(CacheStoreMode cacheStoreMode);
/**
* Set the query timeout, in milliseconds. This is a hint,
* and is an alternative to {@linkplain #setHint setting
* the hint} {@code jakarta.persistence.query.timeout}.
* @param timeout the timeout, in milliseconds, 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,20 @@ public interface EntityTransaction {
* condition is encountered
*/
public boolean isActive();
/**
* Set the transaction timeout, in seconds. This is a hint.
* @param timeout the timeout, in seconds, or null to indicate
* that the database server should set the timeout
* @since 3.2
*/
void setTimeout(Integer timeout);
/**
* The transaction timeout.
* @since 3.2
*/
Integer getTimeout();
}
----

Expand Down

0 comments on commit 92ef50d

Please sign in to comment.