Skip to content
Merged
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
16 changes: 16 additions & 0 deletions ebean-api/src/main/java/io/ebean/UpdateQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,20 @@ public interface UpdateQuery<T> {
*/
int update();

/**
* Return the timeout used to execute this statement.
*/
int getTimeout();

/**
* Set a timeout on this query.
* <p>
* This will typically result in a call to setQueryTimeout() on a
* preparedStatement. If the timeout occurs an exception will be thrown - this
* will be a SQLException wrapped up in a PersistenceException.
* </p>
*
* @param secs the query timeout limit in seconds. Zero means there is no limit.
*/
UpdateQuery<T> setTimeout(int secs);
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,15 @@ public ExpressionList<T> where() {
public int update() {
return query.update();
}

@Override
public int getTimeout() {
return query.timeout();
}

@Override
public UpdateQuery<T> setTimeout(int secs) {
query.setTimeout(secs);
return this;
}
}
10 changes: 10 additions & 0 deletions ebean-test/src/test/java/io/ebean/xtest/base/UpdateQueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,14 @@ private Integer newEbasicWithUnique(String name, String other) {

return b0.getId();
}

@Test
public void timeoutPropagation() {
int timeout = 7;

var updateQuery = DB.update(Customer.class)
.setTimeout(timeout);

assertThat(updateQuery.getTimeout()).isEqualTo(timeout);
}
}
Loading