Open spring-projects-issues opened 6 years ago
Michael Minella commented
Why not just use the JpaPagingItemReader
? The RepositoryItemReader
is intended to go against the Repository
implementation. What you're proposing is really a new FunctionItemReader
that would call a function, but what does it return? What's the contract of the Function
?
Niels Bech Nielsen commented
I know of the JpaPagingItemReader, but if I facilitate Spring Data repositories in my project, I would prefer to be able to use them as well with any batch parts. I was merely highlighting the technical debt I get should I use the RepositoryItemReader. If the method name changes I get an error at runtime. If the set of arguments change I get an error at runtime. If the return value of an innocent repository method changes from Page\
Niels Bech Nielsen opened BATCH-2697 and commented
The JPA implementation org.springframework.batch.item.data.RepositoryItemReader use a loosely typed configuration to request a page of objects.
Currently one needs to:
As well as needing to know that the method
All of this is very fragile to changes, and there is no refactoring tools or type tools to help in this.
Given that none of this is very typesafe, I suggest introduce a function interface similar to:
such that the repository read can be specified more typesafe. One derivative of this interface could use the method invocation of the RepositoryItemReader and have methodName and args injected.
In the below example I use the name 'JPARepositoryItemReader' as the 'new' implementation, and use a Java8 lambda to simply the page reader:
No further details from BATCH-2697