Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RepositoryItemReader#setRepository is broken in 5.0.0-M4 #4164

Closed
makigumo opened this issue Jul 21, 2022 · 2 comments
Closed

RepositoryItemReader#setRepository is broken in 5.0.0-M4 #4164

makigumo opened this issue Jul 21, 2022 · 2 comments

Comments

@makigumo
Copy link

Bug description
With a30aaac in 5.0.0-M4 it is no longer possible to use queries in RepositoryItemReader() or RepositoryItemReaderBuilder that return a different type than the repository's entity type.

Environment
JKD 17.0.3, Spring Boot 3.0.0-M4

Steps to reproduce
Update from Spring Boot 3.0.0-M3 to 3.0.0-M4.

Expected behavior
Same behavior as in .

Minimal Complete Reproducible example

Simplified illustrative example:
Consider something like the following repository.

public interface TestRepository extends JpaRepository<TestEntity, Long> {

    @Query(value = "SELECT e.id FROM TestEntity e")
    Page<String> getFromCustomQuery(Pageable pageable);
}

With the following batch configuration.

@Configuration
public class TestConfig {

    private final TestRepository testRepository;

    @Bean
    @StepScope
    protected RepositoryItemReader<String> testItemReader() throws Exception {
        final var itemReader = new RepositoryItemReader<String>();
        itemReader.setRepository(testRepository);
        itemReader.setPageSize(1000);
        itemReader.setSort(Map.of("id", Sort.Direction.ASC));
        itemReader.setMethodName("getFromCustomQuery");
        itemReader.afterPropertiesSet();
        return itemReader;
    }
}
@makigumo makigumo added status: waiting-for-triage Issues that we did not analyse yet type: bug labels Jul 21, 2022
@makigumo
Copy link
Author

Related/Repeated issue: #1369

@makigumo makigumo changed the title Breaking change in https://github.com/spring-projects/spring-batch/commit/a30aaac4be6bdf66d21a252c87dd5d15b1239bd1 setRepository() in RepositoryItemReader in 5.0.0-M4 broken Jul 21, 2022
@fmbenhassine
Copy link
Contributor

Thank you for raising this! I think the generic type was mistakenly changed as in: b26d272#diff-268ec158a27f386faec50b4fff70ad0fe62c54b4a11cb6a1b146b789b4584d87R68. Will fix that in 5.0 M5.

@fmbenhassine fmbenhassine added in: infrastructure and removed status: waiting-for-triage Issues that we did not analyse yet labels Jul 21, 2022
@fmbenhassine fmbenhassine added this to the 5.0.0-M5 milestone Jul 21, 2022
@fmbenhassine fmbenhassine changed the title setRepository() in RepositoryItemReader in 5.0.0-M4 broken RepositoryItemReader#setRepository is broken in 5.0.0-M4 Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants