diff --git a/jberet-core/src/main/java/org/jberet/repository/JdbcRepository.java b/jberet-core/src/main/java/org/jberet/repository/JdbcRepository.java index b5d6838f..efdecd17 100644 --- a/jberet-core/src/main/java/org/jberet/repository/JdbcRepository.java +++ b/jberet-core/src/main/java/org/jberet/repository/JdbcRepository.java @@ -21,6 +21,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.Timestamp; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -661,7 +662,10 @@ public List getTimeoutJobExecutions(Long timeoutSeconds) { PreparedStatement preparedStatement = null; try { preparedStatement = connection.prepareStatement(query); - preparedStatement.setLong(1, timeoutSeconds); + + Timestamp timeoutTime = Timestamp.from(Instant.now().plusSeconds(timeoutSeconds)); + + preparedStatement.setTimestamp(1, timeoutTime); rs = preparedStatement.executeQuery(); while (rs.next()) { final long executionId = rs.getLong(TableColumns.JOBEXECUTIONID); diff --git a/jberet-core/src/main/resources/sql/jberet-sql.properties b/jberet-core/src/main/resources/sql/jberet-sql.properties index 64c96f90..89d20c25 100644 --- a/jberet-core/src/main/resources/sql/jberet-sql.properties +++ b/jberet-core/src/main/resources/sql/jberet-sql.properties @@ -7,7 +7,7 @@ insert-job-instance = INSERT INTO JOB_INSTANCE(JOBNAME, APPLICATIONNAME) VALUES( select-all-job-executions = SELECT * FROM JOB_EXECUTION select-job-executions-by-job-instance-id = SELECT * FROM JOB_EXECUTION WHERE JOBINSTANCEID=? ORDER BY JOBEXECUTIONID -select-job-executions-by-timeout-seconds = SELECT * FROM JOB_EXECUTION WHERE lastupdatedtime + INTERVAL '? SECOND' < now() +select-job-executions-by-timeout-seconds = SELECT * FROM JOB_EXECUTION WHERE lastupdatedtime < ? AND batchstatus in ('STOPPING', 'STOPPED') select-job-execution = SELECT * FROM JOB_EXECUTION WHERE JOBEXECUTIONID=? select-running-job-executions-by-job-name = SELECT JOB_EXECUTION.JOBEXECUTIONID FROM JOB_EXECUTION \ diff --git a/jberet-core/src/test/java/org/jberet/test/JobRepositoryTest.java b/jberet-core/src/test/java/org/jberet/test/JobRepositoryTest.java index a5a9363e..f91d4842 100644 --- a/jberet-core/src/test/java/org/jberet/test/JobRepositoryTest.java +++ b/jberet-core/src/test/java/org/jberet/test/JobRepositoryTest.java @@ -199,10 +199,4 @@ public void getJobExecutionsByJob() throws Exception { Assertions.assertEquals(1, jobExecutions.size()); } -// @Test -// public void testGetTimeoutJobExecutions() throws Exception { -// List executions = repo.getTimeoutJobExecutions(Long.valueOf(10)); -// System.out.println(executions.size()); -// } - }