mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
use Duration for query timeout
This commit is contained in:
@@ -131,7 +131,7 @@ public interface CommaFeedConfiguration {
|
|||||||
* 0 to disable.
|
* 0 to disable.
|
||||||
*/
|
*/
|
||||||
@WithDefault("0")
|
@WithDefault("0")
|
||||||
int queryTimeout();
|
Duration queryTimeout();
|
||||||
|
|
||||||
Cleanup cleanup();
|
Cleanup cleanup();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.commafeed.backend.dao;
|
package com.commafeed.backend.dao;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
@@ -57,9 +58,9 @@ public abstract class GenericDAO<T extends AbstractModel> {
|
|||||||
return objects.size();
|
return objects.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setTimeout(JPAQuery<?> query, int timeoutMs) {
|
protected void setTimeout(JPAQuery<?> query, Duration timeout) {
|
||||||
if (timeoutMs > 0) {
|
if (!timeout.isZero()) {
|
||||||
query.setHint(SpecHints.HINT_SPEC_QUERY_TIMEOUT, timeoutMs);
|
query.setHint(SpecHints.HINT_SPEC_QUERY_TIMEOUT, timeout.toMillis());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user