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閟

[1747 byte] By [aoguerreroa] at [2007-11-27 6:09:26]
# 1
Why bother with BMT at all? One of the most compelling reasons to use EJB is simple, declarative container-managed transactions
georgemca at 2007-7-12 17:13:18 > top of Java-index,Java Essentials,New To Java...
# 2
Hi, thanks for replying... well I can't leave the transaction to the container, because it locks the tables when performs inserts or updates, and there are other processes in the system using the same tables and the same records.Regards,Andres
aoguerreroa at 2007-7-12 17:13:18 > top of Java-index,Java Essentials,New To Java...