From 9cbde4eea63de7439ddabde3478705a7c230122f Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Wed, 16 Mar 2022 17:15:56 +0100 Subject: [PATCH] Fix RepositoryFunctionalTests Due to the decoupling of `PagingAndSortingRepository` from `CrudRepository` in Spring Data 3 [1], this test has to be updated to use different repositories between the reader and the writer according to the expected types for the `repository` property. [1]: https://github.com/spring-projects/spring-data-commons/issues/2537 --- .../data/CustomerCreditCrudRepository.java | 23 +++++++++++++++++++ ...omerCreditPagingAndSortingRepository.java} | 4 ++-- .../resources/jobs/iosample/repository.xml | 4 ++-- 3 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditCrudRepository.java rename spring-batch-samples/src/main/java/org/springframework/batch/sample/data/{CustomerCreditRepository.java => CustomerCreditPagingAndSortingRepository.java} (84%) diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditCrudRepository.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditCrudRepository.java new file mode 100644 index 000000000..8593bdba7 --- /dev/null +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditCrudRepository.java @@ -0,0 +1,23 @@ +/* + * Copyright 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.batch.sample.data; + +import org.springframework.batch.sample.domain.trade.CustomerCredit; + +import org.springframework.data.repository.CrudRepository; + +public interface CustomerCreditCrudRepository extends CrudRepository { +} diff --git a/spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditRepository.java b/spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditPagingAndSortingRepository.java similarity index 84% rename from spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditRepository.java rename to spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditPagingAndSortingRepository.java index bccf791c9..5f2bf7a26 100644 --- a/spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditRepository.java +++ b/spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditPagingAndSortingRepository.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,6 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.repository.PagingAndSortingRepository; -public interface CustomerCreditRepository extends PagingAndSortingRepository{ +public interface CustomerCreditPagingAndSortingRepository extends PagingAndSortingRepository{ Page findByCreditGreaterThan(BigDecimal credit, Pageable request); } diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/repository.xml b/spring-batch-samples/src/main/resources/jobs/iosample/repository.xml index e82d7fef7..92b517746 100644 --- a/spring-batch-samples/src/main/resources/jobs/iosample/repository.xml +++ b/spring-batch-samples/src/main/resources/jobs/iosample/repository.xml @@ -11,7 +11,7 @@ class="org.springframework.batch.item.data.RepositoryItemReader" scope="step"> - + #{new java.math.BigDecimal(jobParameters[credit])} @@ -27,7 +27,7 @@ - +