Skip to content

RepositoryItemReader#setRepository is broken in 5.0.0-M4 #4164

Closed
@makigumo

Description

@makigumo

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;
    }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions