-
1. Re: Transaction-Status
adrian.brock Apr 30, 2003 10:05 AM (in response to trugbild)There are methods on the bean context
to control the transaction.
public boolean getRollbackOnly() ;
public void setRollbackOnly();
Regards,
Adrian -
2. Re: Transaction-Status
trugbild Apr 30, 2003 10:23 AM (in response to trugbild)Thanks for your answer, but this is not exactly what I wanted to know...
I do not want to CHANGE the status, only GET it. -
3. Re: Transaction-Status
adrian.brock Apr 30, 2003 10:31 AM (in response to trugbild)What is wrong with getRollbackOnly() ?
You can use the TransactionManger bound at
"java:/TransactionManager" to access the transaction.
Regards,
Adrian -
4. Re: Transaction-Status
trugbild Apr 30, 2003 10:43 AM (in response to trugbild)> What is wrong with getRollbackOnly() ?
It only returns if the transaction is going to be rolled back or not.
But there are several other status, like "active" or "prepared". But in the j2ee-API-Documentation I found, that the method "getUserTransaction()" is available for SessionContext-objects. So I try this one first...
I think I would get the same object if I get the Transaction via TransactionManager, is this correct? -
5. Re: Transaction-Status
adrian.brock Apr 30, 2003 11:19 AM (in response to trugbild)UserTranscations are for BMT (bean managed transactions).
The other statuses don't apply inside the bean
for CMT. You are either active or marked rollback.
The other statuses apply at the end of the work
when the container is committing/rolling back the
transaction.
Regards,
Adrian -
6. Re: Transaction-Status
trugbild May 1, 2003 4:51 AM (in response to trugbild)So the getUserTransaction() only returns an object, if I invoked the bean from within a bean-managed transaction? And if I control the transaction with a servlet?
And with container-managed transaction getUserTransaction returns null?
hmm... perhaps I should try it... -
7. Re: Transaction-Status
trugbild May 1, 2003 5:40 AM (in response to trugbild)By the way:
I wonder what happens to transactions if they get suspended (e.g. when a method in a transaction invokes another method which is set to RequiresNew) -
8. Re: Transaction-Status
adrian.brock May 1, 2003 6:24 AM (in response to trugbild)The getUserTransaction() method
creates a UT when one is not already assigned
to the bean.
For CMT it throws an exception.
For BMT any previous transaction is suspended.
If you invoke a RequiresNew method your
transaction is suspended, but it is activated again
by the time it returns to your method.
So the suspension is invisible to you.
Regards,
Adrian -
9. Re: Transaction-Status
trugbild May 1, 2003 8:05 AM (in response to trugbild)I know that it isn't my business how a transaction gets suspended and how it is activated again. But I would really like to know (only the essence of it - no details, of course).
Remember my statement about the documentation?
Maybe you're glad to here, that I begun writing a tutorial about transactions, yesterday... (in German).
I'm reading and testing all the time. I'll put it on the web when it's finished...
Thanks for your help!