Announcement Announcement Module
Collapse
No announcement yet.
whole steps are rollback? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • whole steps are rollback?

    I've a case look like this:

    jobA
    step1 -> insert to db
    step2 -> insert to db


    if an exception occur in step2, I want to rollback the data that have been inserted in step1...

    how can I do that??
    any suggestions?
    thank in advance??

  • #2
    The most obvious answer to this question is "wrap the Job.execute() method in a transaction". That would work as you described, but it would lead to problems with restartability unless you also wrap the JobLauncher and update the JobExecution to show that it failed. I never tried it, so consider this advanced usage.

    Addendum: you need to wrap the Step as well, so that you can throw an exception when it fails.
    Last edited by Dave Syer; Mar 25th, 2009, 04:28 AM. Reason: More detail...

    Comment


    • #3
      Dave,

      Thx for the quick response

      Comment

      Working...
      X