Any experience of using ItemReader and ItemWriter from Spring batch

Hi, I need to perform a long batch operation on a quite large dataset. The batch pattern from Spring appears very clean and useful, and I would like to implement it.

My question is mainly about the implementation of the ItemReader, working with pagination.
I would like to use DaaManager, while the closest concrete implementation offered by Spring is
JpaPagingItemReader

My main doubt is how to get an entityManagerFactory that maps to JMix DataManager.

Hi @massimo.coletti ,

Without having looked deep into it, it seems that you can just use the JPA implementation from spring batch out of the box.

The entityManagerFactory bean is automatically instantiated by the jmix-eclipselink module. See: https://github.com/Haulmont/jmix-data/blob/master/eclipselink-starter/src/main/java/io/jmix/autoconfigure/eclipselink/EclipselinkAutoConfiguration.java#L50

The sample code of your linked docs should work as is if I understand correctly. The entityManagerFactory() method just references the spring bean. So you probably can leave it as is.

Or is there any other reason you need to use the DataManager API?

Cheers
Mario

1 Like