Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate user transaction

 
bujin wang
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using hibernate to persist our data. We have a user sign up screen and we ask for credit card number. we associate credit card number with a user account during the registration process. We create a userAccount and persist to database and then try to register credit card for the user.

The credit card registration process is a seperate process running as a daemon . It's a network application. Our problem is that we have to have a user account to register a credit card(due to the original design). But the credit card registration process could fail(network or other exceptions).

My question is how could we group these two actions(user account persistence and credit card registration) into one transaction, so that if the credit card registration process fails we could roll back the userAccount persistence?

Currently we delete the user Account if credit card registration fails.

Any suggestions?


Thanks,
Burt
Burt
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to wrap the whole business transaction is a JTA transaction. It will need to be an XA transaction, since you are using both a DB and a networked app. So your JDBC driver will have to support two-phase commit.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic