Skip to content

Commit b7e7f91

Browse files
fmbenhassinelcmarvin
authored andcommitted
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]: spring-projects/spring-data-commons#2537
1 parent 13a5164 commit b7e7f91

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.batch.sample.data;
17+
18+
import org.springframework.batch.sample.domain.trade.CustomerCredit;
19+
20+
import org.springframework.data.repository.CrudRepository;
21+
22+
public interface CustomerCreditCrudRepository extends CrudRepository<CustomerCredit, Long> {
23+
}

spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditRepository.java renamed to spring-batch-samples/src/main/java/org/springframework/batch/sample/data/CustomerCreditPagingAndSortingRepository.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013 the original author or authors.
2+
* Copyright 2013-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.
@@ -22,6 +22,6 @@
2222
import org.springframework.data.domain.Pageable;
2323
import org.springframework.data.repository.PagingAndSortingRepository;
2424

25-
public interface CustomerCreditRepository extends PagingAndSortingRepository<CustomerCredit, Long>{
25+
public interface CustomerCreditPagingAndSortingRepository extends PagingAndSortingRepository<CustomerCredit, Long>{
2626
Page<CustomerCredit> findByCreditGreaterThan(BigDecimal credit, Pageable request);
2727
}

spring-batch-samples/src/main/resources/jobs/iosample/repository.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class="org.springframework.batch.item.data.RepositoryItemReader" scope="step">
1212
<property name="pageSize" value="2"/>
1313
<property name="methodName" value="findByCreditGreaterThan"/>
14-
<property name="repository" ref="customerCreditRepository"/>
14+
<property name="repository" ref="customerCreditPagingAndSortingRepository"/>
1515
<property name="arguments">
1616
<list>
1717
<value>#{new java.math.BigDecimal(jobParameters[credit])}</value>
@@ -27,7 +27,7 @@
2727
<bean id="itemWriter"
2828
class="org.springframework.batch.item.data.RepositoryItemWriter">
2929
<property name="methodName" value="save"/>
30-
<property name="repository" ref="customerCreditRepository"/>
30+
<property name="repository" ref="customerCreditCrudRepository"/>
3131
</bean>
3232

3333
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">

0 commit comments

Comments
 (0)