Thanks
guys, I got it now.
Hi,
Even
though bean uses container managed transactions, container knows only
EJBException.
It catches only
EJBException and in that case it automatically marked particular transaction
for rollback.
But if your
application is throwing a non-EJBException then container is not able to catch
that exception and it just throw it.
In order to rollback transaction, call rollback methd and set rollback
flag as true then wrap application exception in EJBException and just
throw it.
Afterwards it altogether
container's responsibility to mark this transaction for rollback and send
notification to transaction manager for rollback...and so on......
Hope this will help u to understand how
container handles rollback automatically.....
Milind Bhaskar Patil
Tata Consultancy Services
Limited
Mailto: [EMAIL PROTECTED]
Website: http://www.tcs.com
Suresh Babu Koya
<[EMAIL PROTECTED]> Sent by: A mailing list for Enterprise JavaBeans development
<[EMAIL PROTECTED]>
16/12/2004 18:07
|
Please respond
to [EMAIL PROTECTED] |
|
|
To
| [EMAIL PROTECTED]
|
|
cc
|
|
|
Subject
| Issues in calling DAO
from Sateless session bean |
|
I have a stateless session bean which uses container managed
transactions. I had to call
a DAO in which
I insert two records, from the session bean. If there is an exception while
inserting
second record in the DAO, I am
facing the problem that the first record is already commited
inspite of throwing the Exception.
I was able to have a
workaround by calling setRollbackonly on the transaction context. I am not
sure
why this should be done. If the
transactions are managed by container and I am not calling commit
explicitly why should I call
setRollbackonly.
Does anyone have any idea why this works this way?
Regards,
Koya Suresh
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of
the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
ForwardSourceID:NT00002D9E
Notice: The information
contained in this e-mail message and/or attachments to it may contain
confidential or privileged information. If you are not the intended
recipient, any dissemination, use, review, distribution, printing or
copying of the information contained in this e-mail message and/or
attachments to it are strictly prohibited. If you have received this
communication in error, please notify us by reply e-mail or telephone
and immediately and permanently delete the message and any attachments.
Thank
you
|
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of
the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".