spring-projects / spring-projects/spring-batch

Unable to use projections in ItemReader

Open
#4,665 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

While tyring to use projections in item reader, always getting "NoSuchMethodException" (for the projection method in jpa repository). Tried multiple ways, although same works when invoking via say a controller.
Error:
Caused by: java.lang.NoSuchMethodException: jdk.proxy2.$Proxy115.findDistinctByCreatedAfter(java.time.LocalDate,org.springframework.data.domain.PageRequest)
at java.base/java.lang.Class.getMethod(Class.java:2405) ~[na:na]

Env: Spring Boot 3.X, JDK 17

Created a github demo project with all set up to demonstrate issue runtime
https://github.com/jobas2007/batch-h2-demo

Expected behavior is to be able to use projection fitting into batch processing

All details are in the stackoverflow
https://stackoverflow.com/questions/79002944/purge-group-of-old-records-iteratively-to-insert-fresh-data-daily

Appreciate any help/assistance/suggestions, as been struggling for a while now. Thanks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the linked batch-h2-demo and reproduce the NoSuchMethodException from the ItemReader projection path. Compare that behavior with the controller invocation described in the issue, then verify that the projection method works during batch processing without the exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, spring-boot
Domain
backend, database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.