Announcement Announcement Module
Collapse
No announcement yet.
Exception during commit does not cause step to fail Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception during commit does not cause step to fail

    Hi
    I have a problem that I'd appreciate some help with.
    We have a job step that is writing entites to an Oracle DB in chunks, using hibernate. Sometimes, because of user mistake, the length of some field is too large and a java.sql.BatchUpdateException is thrown during the commit of the transaction. So far it is fine, but for some reason after this exception happens, the step is not failed but is marked as completed. Here is the exception stack trace:

    Code:
    2012-01-09 10:59:00,132 ERROR 	 org.hibernate.event.def.AbstractFlushingEventListener.performExecutions 	 Could not synchronize database state with session
    org.hibernate.QueryTimeoutException: Could not execute JDBC batch update
    	at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:124)
    	at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:262)
    	at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:178)
    	at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
    	at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
    	at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1206)
    	at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
    	at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
    	at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)
    	at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:467)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
    	at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
    	at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:147)
    	at org.springframework.batch.core.step.tasklet.TaskletStep$2.doInChunkContext(TaskletStep.java:264)
    	at org.springframework.batch.core.scope.context.StepContextRepeatCallback.doInIteration(StepContextRepeatCallback.java:76)
    	at org.springframework.batch.repeat.support.RepeatTemplate.getNextResult(RepeatTemplate.java:367)
    	at org.springframework.batch.repeat.support.RepeatTemplate.executeInternal(RepeatTemplate.java:214)
    	at org.springframework.batch.repeat.support.RepeatTemplate.iterate(RepeatTemplate.java:143)
    	at org.springframework.batch.core.step.tasklet.TaskletStep.doExecute(TaskletStep.java:250)
    	at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:195)
    	at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)
    	at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)
    	at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
    	at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
    	at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
    	at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)
    	at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
    	at java.lang.Thread.run(Unknown Source)
    Caused by: java.sql.BatchUpdateException: ORA-12899: value too large for column "ALEXZ4"."AZ_UNIT"."NAME" (actual: 631, maximum: 255)
    
    	at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:629)
    	at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:9409)
    	at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:211)
    	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeBatch(NewProxyPreparedStatement.java:1723)
    	at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
    	at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
    	... 28 more
    Thanks in advance!

  • #2
    do you use the HibernateItemWriter ? if no, when do you flush the session?

    Comment


    • #3
      Hi
      Sorry for not answering for some time, I was assigned to other tasks and did not meet this problem until recently.
      Thanks to you I now understand that the problem is that I did not call flush() at end of write method, and did not use HibernateItemWriter /JpaItemWriter.
      If I do either it works correctly - the exception is thrown in the step and the step fails.

      But I do not want to have references to the persistence layer in my logic layer. Is there any way around it?

      Comment

      Working...
      X