Skip to content

Commit 30166a8

Browse files
committed
Revert "Improve generic type handling in RepositoryItemReader"
This reverts commit a30aaac which had the side effect of no longer being able to use queries in `RepositoryItemReader` that return a different type than the repository's entity type. Resolves #4164
1 parent 96c6367 commit 30166a8

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/RepositoryItemReader.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2020 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.
@@ -76,14 +76,13 @@
7676
*
7777
* @author Michael Minella
7878
* @author Antoine Kapps
79-
* @author Mahmoud Ben Hassine
8079
* @since 2.2
8180
*/
8281
public class RepositoryItemReader<T> extends AbstractItemCountingItemStreamItemReader<T> implements InitializingBean {
8382

8483
protected Log logger = LogFactory.getLog(getClass());
8584

86-
private PagingAndSortingRepository<T, ?> repository;
85+
private PagingAndSortingRepository<?, ?> repository;
8786

8887
private Sort sort;
8988

@@ -133,7 +132,7 @@ public void setPageSize(int pageSize) {
133132
* implementation used to read input from.
134133
* @param repository underlying repository for input to be read from.
135134
*/
136-
public void setRepository(PagingAndSortingRepository<T, ?> repository) {
135+
public void setRepository(PagingAndSortingRepository<?, ?> repository) {
137136
this.repository = repository;
138137
}
139138

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/data/builder/RepositoryItemReaderBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
*/
4444
public class RepositoryItemReaderBuilder<T> {
4545

46-
private PagingAndSortingRepository<T, ?> repository;
46+
private PagingAndSortingRepository<?, ?> repository;
4747

4848
private Map<String, Sort.Direction> sorts;
4949

@@ -165,7 +165,7 @@ public RepositoryItemReaderBuilder<T> pageSize(int pageSize) {
165165
* @return The current instance of the builder.
166166
* @see RepositoryItemReader#setRepository(PagingAndSortingRepository)
167167
*/
168-
public RepositoryItemReaderBuilder<T> repository(PagingAndSortingRepository<T, ?> repository) {
168+
public RepositoryItemReaderBuilder<T> repository(PagingAndSortingRepository<?, ?> repository) {
169169
this.repository = repository;
170170

171171
return this;

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/data/RepositoryItemReaderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2013-2022 the original author or authors.
2+
* Copyright 2013-2021 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.
@@ -343,7 +343,7 @@ public void testResetOfPage() throws Exception {
343343
assertEquals("3", reader.read());
344344
}
345345

346-
public interface TestRepository extends PagingAndSortingRepository<String, Long> {
346+
public interface TestRepository extends PagingAndSortingRepository<Map, Long> {
347347

348348
Page<String> findFirstNames(Pageable pageable);
349349

0 commit comments

Comments
 (0)