I started using Spring Batch (version 4.1.2) with SpringBoot(version 2.1.7). Now I generate reports in csv format and save them to the file system. My next step is to save the file to the database in binary format. The tutorials and examples show how to save entities FROM strings in csv files, but I can't figure out how to save the whole file in binary.
I will be grateful for any advice! Here are my steps for now:
<bean id="jdbcItemReader" class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="job">
<property name="dataSource" ref="dataSource"/>
<property name="rowMapper">
<bean class="org.springframework.jdbc.core.ColumnMapRowMapper"/>
</property>
<property name="sql" value="#{jobParameters['sql']}"/>
<property name="preparedStatementSetter">
<bean class="ru.bpc.otter.batch.PreparedStatementSetter">
<constructor-arg value="#{jobParameters}"/>
</bean>
</property>
</bean>
<bean id="csvItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="job">
<property name="resource" value="file://#{jobParameters['file.name']}"/>
<property name="lineAggregator">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator">
<property name="delimiter" value=";"/>
<property name="fieldExtractor">
<bean class="org.springframework.batch.item.file.transform.PassThroughFieldExtractor"/>
</property>
</bean>
</property>
</bean>
<bean class="org.springframework.batch.core.scope.JobScope"/>
<batch:job id="generateReportJob" restartable="false">
<batch:step id="generateReportStep">
<batch:tasklet>
<batch:chunk reader="jdbcItemReader" writer="csvItemWriter" commit-interval="${commit.interval:10000}"/>
</batch:tasklet>
</batch:step>
</batch:job>