Open jobas2007 opened 2 months ago
You can use the RepositoryItemReader
also with projections. But there are conditions that need to be fulfilled:
Pageable
. See e.g. the Javadoc of the methodName
on the builder.Slice
, in particular not List
.So if I add the following to your CountryDistinctView
Integer getId();
and the following to your CountyRepository
Slice<CountryDistinctView> findDistinctByCreatedAfter(LocalDate created, Pageable pageable);
then your sample app seems okay to me.
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