Transactional rollBack if something goes wrong in the internal database.
I splitted the datasource for the Business object from the datasource used by Spring Batch. And my problem is that if I cause a runtime exception while the database job data is inserted (like a DAtaIntegrityViolation changing a column type in the BATCH_STEP_EXECUTION table) then the rollback on the JOB_EXECUTION table is not done... I would expect all the data inserted regarding the job to be removed from the database.
I'm using Hibernate for my domain and I defined a session factory for my object:
referred by a:
then I have another transaction manager:
referring to the batch data source.
I configured this advice:
p:databaseType="mysql" p:dataSource-ref="batchDataSource" />
pointcut="execution(* org.springframework.batch.core..*Repository+.*(..) )"
<tx:method name="*" propagation="REQUIRED_NEW"
isolation="SERIALIZABLE" read-only="false" />
<tx:method name="*" />
as seen in the sample; only changing the method name to * because actually my exception arises when the method:
public void saveOrUpdate(StepExecution stepExecution)
is called in the SimpleJobRepository.
But what happen is that the exception is thrown when trying to insert the step_execution data but the row in the job_execution table remains. I also tried changing REQUIRED_NEW to REQUIRE but without any success. Any glue or suggestion on it? Is it because I'm not using a JtaTransactionManager?
I need to be sure that neither the internal database used by Spring batch doesn't risk to be missed up if a runtime exception arise when persisting the job repository data.
Thanks in advance,