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
This commit is contained in:
Mahmoud Ben Hassine
2022-03-16 17:15:56 +01:00
parent 905630d521
commit 9cbde4eea6
3 changed files with 27 additions and 4 deletions

View File

@@ -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<CustomerCredit, Long> {
}

View File

@@ -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<CustomerCredit, Long>{
public interface CustomerCreditPagingAndSortingRepository extends PagingAndSortingRepository<CustomerCredit, Long>{
Page<CustomerCredit> findByCreditGreaterThan(BigDecimal credit, Pageable request);
}

View File

@@ -11,7 +11,7 @@
class="org.springframework.batch.item.data.RepositoryItemReader" scope="step">
<property name="pageSize" value="2"/>
<property name="methodName" value="findByCreditGreaterThan"/>
<property name="repository" ref="customerCreditRepository"/>
<property name="repository" ref="customerCreditPagingAndSortingRepository"/>
<property name="arguments">
<list>
<value>#{new java.math.BigDecimal(jobParameters[credit])}</value>
@@ -27,7 +27,7 @@
<bean id="itemWriter"
class="org.springframework.batch.item.data.RepositoryItemWriter">
<property name="methodName" value="save"/>
<property name="repository" ref="customerCreditRepository"/>
<property name="repository" ref="customerCreditCrudRepository"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">