I want to use Spring Batch and Spring Integration to import data from database and write them into a file and ftp them to a remote server.
But I guess my problem is I don’t want to create Domain Object for my table. My queries are random and I want something that just reads the data and writes it to files and transfer.
Can I use Spring Batch and Integration without creating respective domain objects?
Absolutely. You can use either of the JDBC
ItemReaders or the JPAItemReaderwith aColumnMapRowMapperto retrieve aMapof the result set. You can use theFlatFileItemWriterpretty simply to output the data in whatever format you like (delimited being very easy with the provided classes; fixed width means writing one class to translate theMapto your fixed width string).I do this pretty often with Spring Batch and it’s pretty much just a matter of wiring things up.
Aside from defining a resource, data source, and providing the SQL, this (untested) configuration would pretty much do exactly what you’re asking: