aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate user transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate user transaction" Watch "Hibernate user transaction" New topic
Author

Hibernate user transaction

bujin wang
Ranch Hand

Joined: Jun 21, 2003
Posts: 48
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

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
 
subject: Hibernate user transaction