Have a question that relates to Hibernate flushing (JIRA: BATCH-194)
We have our own persistence framework here that is currently under revision of adding a client's flush flag to enable an auto flush ("hibernateTemplate.flush()") on any CRUD (well CUD really).
But for now we need the Hibernate Template to flush after each item is processed (or "written", as they say now days). Simple reason would be a "DataIntegrityViolationException" that is thrown outside of the ItemWriter in ItemOrientedStep:
and therefore is not intercepted by "public void onWriteError(Exception ex, Object item)".Code:try { itemHandler.mark(); // should not mark() be called after commit, in case if commit fails? :-/ transactionManager.commit(transaction); // <-- exception here, since there was no flush } catch (Exception e) { fatalException.setException(e); stepExecution.setStatus(BatchStatus.UNKNOWN); logger.error("Fatal error detected during commit."); throw new FatalException("Fatal error detected during commit", e); }
I know that you guys have a "HibernateAwareItemWriter" (from samples):
But we already have existing ItemWriters that we would not want to re-write, or wrap all of them in "HibernateAwareItemWriter".Code:<!-- This is a framework class that needs a delegate and also needs to be registered as a RepeatInterceptor in the chunk --> <bean id="hibernateItemWriter" class="org.springframework.batch.item.database.HibernateAwareItemWriter"> <property name="sessionFactory" ref="sessionFactory" /> <property name="delegate" ref="hibernateCreditWriter" /> </bean>
Any other current solution available in 1.0.1 (besides AOP)?
( What we need is simple: to catch any exceptions that are caused in ItemWriter by "public void onWriteError" method, so the item can be skipped, or acted upon exception accordingly )
Thank you.


). Simple reason would be a "DataIntegrityViolationException" that is thrown outside of the ItemWriter in ItemOrientedStep:
Reply With Quote
