• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to rollback in components those have their own transaction?  RSS feed

 
Rudy Harianto
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all..

Imagine this condition:
We have, say, 3 components. Each component is use for inserting data into table ONE, TWO, and THREE. And they have their own transaction.
We have a main thread which is call the three components above in sequence.
If one of those components is fail, then the whole three should be rolled back.

Now the question is: how can we implement the rollback action?

Thanks.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wrap the whole operation in a Transaction. Have a look at JTA.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36393
453
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to J2EE because the question is more about transactions than JDBC in particular.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your components start their own transaction you cannot
take any influence in these from your main component. You could
check in the 3 components if they were called in he context of a running
transaction and then use this one instead of creating a new one.

Remember the definition of a transaction. If component 3 fails then
component 1 and 2 were already commited, which means there is no longer any information about the former state.

If you wrap it you can't wrap the transaction by another transaction. Normally this only means the main transaction is simply suspended when the
new one is started.

Hope that helps
Olli
Originally posted by Rudy Harianto:
Hi all..

Imagine this condition:
We have, say, 3 components. Each component is use for inserting data into table ONE, TWO, and THREE. And they have their own transaction.
We have a main thread which is call the three components above in sequence.
If one of those components is fail, then the whole three should be rolled back.

Now the question is: how can we implement the rollback action?

Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!