Announcement Announcement Module
Collapse
No announcement yet.
Question for TaskletStep.doExecute method code in spring batch 2.0.4 release Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question for TaskletStep.doExecute method code in spring batch 2.0.4 release

    Hi,

    In my project I am facing a weird issue after writing contents onto destination DB. I have created a custom writer using ItemWriter, and after persisting data to db, code flow is going to TaskletStep.doExecute method and by following lines of code, it is trying to persist entity once again which is not at all desired.

    try {
    getJobRepository().updateExecutionContext(stepExec ution);
    transactionManager.commit(transaction);
    stepExecution.incrementCommitCount();
    logger.debug("Saving step execution after commit: " + stepExecution);
    getJobRepository().update(stepExecution);
    }


    Please help if we can skip this extra data persistence.
    Quick help will be appreciated. TIA

  • #2
    I think this is where the framework commits the transaction for the chunk and the execution context. I don't think you can skip this.

    Comment


    • #3
      Question for TaskletStep.doExecute method code in spring batch 2.0.4 release

      Thanks Arno for instant reply.

      I will try to explain the problem further.
      As we have 2-3 flavors of writer available in Spring Batch and those are ItemWriter, HibernateItemWriter and JdbcItemWriter. I have created my custom writer by implementing ItemWriter because I have my own sql code to persist data and in that case I don't want framework to commits the transaction for the chunk. That's why I was looking to skip this persistence code.

      See if you can help me further.

      TIA

      Comment


      • #4
        you can control transaction attributes and so disable transactions: http://static.springsource.org/sprin...tionAttributes

        that's perhaps what you're looking for. I don't really see the point: remember Spring Batch controls transactions for efficiency and reliability, you shouldn't try to manage transactions in application code (unless for specific needs and if you know what you're doing.)

        Comment

        Working...
        X