This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate user transaction" Watch "Hibernate user transaction" New topic

Hibernate user transaction

bujin wang
Ranch Hand

Joined: Jun 21, 2003
Posts: 48

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?

Paul Sturrock

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
I agree. Here's the link:
subject: Hibernate user transaction
It's not a secret anymore!