MongoItemReader deprecated in Spring boot 3.2.2- how to use MongoPagingItemReader

135 Views Asked by At

I recently upgraded my app from Spring boot 3.0.6 to 3.2.2.I have a batch process that is partitioned and using MongoItemReader. After upgrade MongoItemReader shows deprecated and Spring suggest to use MongoPagingItemReader. But after upgrade, the methods setTemplate,setQuery and setTargetType are showing deprecated as these are inherited methods from MongoItemReader.

https://docs.spring.io/spring-batch/docs/current/api/org/springframework/batch/item/data/MongoPagingItemReader.html

Below is the screenshot of the reader.

enter image description here

I tried to use something similar to JdbcPagingItemreader but there is no queryprovider for mongoDB.

http://www.java2s.com/example/java-api/org/springframework/batch/item/database/jdbcpagingitemreader/setqueryprovider-1-0.html

Appreciate any help on how to use MongoPagingItemReader without any deprecated methods.

1

There are 1 best solutions below

0
Mahmoud Ben Hassine On

These deprecations should disappear when the deprecated MongoItemReader will be removed (in Spring Batch 5.3+). But this is currently incorrect and those inherited methods should not be marked as deprecated in MongoPagingItemReader.

I created an issue for that: https://github.com/spring-projects/spring-batch/issues/4552. It will be fixed in the next patch release v5.1.1.