Skip to content

Commit 2edd400

Browse files
committed
Change the return type of counting methods in various DAOs from int to long
This is required for job repository/explorer implementations that use the Long type to count records in the database. Resolves #4227
1 parent 919f73e commit 2edd400

File tree

18 files changed

+26
-26
lines changed

18 files changed

+26
-26
lines changed

spring-batch-core/src/main/java/org/springframework/batch/core/explore/JobExplorer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,6 @@ default JobExecution getLastJobExecution(JobInstance jobInstance) {
153153
* @throws NoSuchJobException thrown when there is no {@link JobInstance} for the
154154
* jobName specified.
155155
*/
156-
int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException;
156+
long getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException;
157157

158158
}

spring-batch-core/src/main/java/org/springframework/batch/core/explore/support/SimpleJobExplorer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public List<String> getJobNames() {
226226
* String)
227227
*/
228228
@Override
229-
public int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
229+
public long getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
230230
return jobInstanceDao.getJobInstanceCount(jobName);
231231
}
232232

spring-batch-core/src/main/java/org/springframework/batch/core/job/flow/JobFlowExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2018 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@ public String executeStep(Step step)
8484
}
8585

8686
private boolean isStepRestart(Step step) {
87-
int count = jobRepository.getStepExecutionCount(execution.getJobInstance(), step.getName());
87+
long count = jobRepository.getStepExecutionCount(execution.getJobInstance(), step.getName());
8888

8989
return count > 0;
9090
}

spring-batch-core/src/main/java/org/springframework/batch/core/repository/JobRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ JobExecution createJobExecution(String jobName, JobParameters jobParameters)
199199
* @param stepName the name of the step execution that might have run.
200200
* @return the execution count of the step within the given job instance.
201201
*/
202-
int getStepExecutionCount(JobInstance jobInstance, String stepName);
202+
long getStepExecutionCount(JobInstance jobInstance, String stepName);
203203

204204
/**
205205
* @param jobName the name of the job that might have run

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcJobInstanceDao.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ public JobInstance getJobInstance(JobExecution jobExecution) {
268268
* java.lang.String)
269269
*/
270270
@Override
271-
public int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
271+
public long getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
272272

273273
try {
274-
return getJdbcTemplate().queryForObject(getQuery(COUNT_JOBS_WITH_NAME), Integer.class, jobName);
274+
return getJdbcTemplate().queryForObject(getQuery(COUNT_JOBS_WITH_NAME), Long.class, jobName);
275275
}
276276
catch (EmptyResultDataAccessException e) {
277277
throw new NoSuchJobException("No job instances were found for job name " + jobName);

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ public void addStepExecutions(JobExecution jobExecution) {
358358
}
359359

360360
@Override
361-
public int countStepExecutions(JobInstance jobInstance, String stepName) {
362-
return getJdbcTemplate().queryForObject(getQuery(COUNT_STEP_EXECUTIONS), Integer.class,
361+
public long countStepExecutions(JobInstance jobInstance, String stepName) {
362+
return getJdbcTemplate().queryForObject(getQuery(COUNT_STEP_EXECUTIONS), Long.class,
363363
jobInstance.getInstanceId(), stepName);
364364
}
365365

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JobInstanceDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ default JobInstance getLastJobInstance(String jobName) {
128128
* repository
129129
* @throws NoSuchJobException thrown if no Job has the jobName specified.
130130
*/
131-
int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException;
131+
long getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException;
132132

133133
/**
134134
* Delete the job instance.

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/StepExecutionDao.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ default StepExecution getLastStepExecution(JobInstance jobInstance, String stepN
8787
* @since 4.3
8888
* @return the count of {@link StepExecution}s for a given step
8989
*/
90-
default int countStepExecutions(JobInstance jobInstance, String stepName) {
90+
default long countStepExecutions(JobInstance jobInstance, String stepName) {
9191
throw new UnsupportedOperationException();
9292
}
9393

spring-batch-core/src/main/java/org/springframework/batch/core/repository/support/SimpleJobRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public StepExecution getLastStepExecution(JobInstance jobInstance, String stepNa
242242
* @return number of executions of the step within given job instance
243243
*/
244244
@Override
245-
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
245+
public long getStepExecutionCount(JobInstance jobInstance, String stepName) {
246246
return stepExecutionDao.countStepExecutions(jobInstance, stepName);
247247
}
248248

spring-batch-core/src/test/java/org/springframework/batch/core/configuration/xml/DummyJobRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2021 the original author or authors.
2+
* Copyright 2006-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -70,7 +70,7 @@ public StepExecution getLastStepExecution(JobInstance jobInstance, String stepNa
7070
}
7171

7272
@Override
73-
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
73+
public long getStepExecutionCount(JobInstance jobInstance, String stepName) {
7474
return 0;
7575
}
7676

0 commit comments

Comments
 (0)