Reputation: 815
I have been trying to create a Spring batch program which has to read certain data from Database and write it into another table. I don't want the Spring Batch metadata tables to be created in my Database. When I tried that, I was not able to do the transactions.
I avoided the meta data tables by extending DefaultBatchConfigurer
and overriding like this,
@Override
public void setDataSource(DataSource dataSource) {
// override to do not set datasource even if a datasource exist.
// initialize will use a Map based JobRepository (instead of database)
}
By doing this I was getting org.springframework.dao.InvalidDataAccessApiUsageException: no transaction is in progress; nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress
exception.
Is there a way by which I can avoid the metadata tables and still use the transactions?
Upvotes: 2
Views: 2126
Reputation: 96
spring.batch.initializer.enabled=false
Also since you do not need the meta tables so do not extend DefaultBatchConfigurer
class.
I would only extend this class if I want to set up a persistent JobRepository
i.e. create the spring batch meta tables, for which we need a lot of other configurations that are provided by default by DefaultBatchConfigurer
class.
Upvotes: 1