UserTransaction

A

Andres G.

Hi, I'm working in an EJB with transactions handled by the bean, I use
the UserTransaction object to start and finish each transaction, the
EJB has some code like this:

/* ************************* */
ut.begin();
try {
/* An insert or update query */
ut.commit()
} catch (Exception e) {
ut.rollback();
}
.. . .
/* OtherClass was made by somebody else, I only have the jar file not
the source code */
OtherClass otherClass = new OtherClass();
otherClass.setTransaction(ut);
otherClass.doStuff();
.. . .
ut.begin();
try {
/* An insert or update query */
ut.commit()
} catch (Exception e) {
ut.rollback();
}
/* ************************* */

This code can produce errors when the code in the class "OtherClass",
begins a transaction and doesn't execute ut.commit() or ut.rollback().

I know that there is a method called ut.getStatus() that returns the
state of the thread's transaction, my question is, which is the best
way to check the transaction status and execute well ut.commit() or
ut.rollback() ?

Thanks,

Andrés
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,351
Members
48,036
Latest member
nickwillsonn

Latest Threads

Top