Hi,
Container will automatically rollback Transactions only in a case of
Runtime Exceptions. If u want to rollback a transactions in a case of
Application exceptions we need to explicitly call setRollbackOnly() method
on the Context.
SQLException doesn;t extend Runtime Excption so we have to call
setRollbackOnly method.
-Satish
-----Original Message-----
From: Peter Verkest [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 28, 2001 6:21 PM
To: [EMAIL PROTECTED]
Subject: Re: Transactions not being handled properly in Stateless
Session bean s with CMT
Hement,
AFAIK SQLException is an application exception, so, yes, you have to use
setRollbackOnly.
---
Peter Verkest
Hement Sasan <[EMAIL PROTECTED]> on 28/12/2001 12:52:01
Please respond to [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc: (bcc: Peter Verkest/I/SECUREX)
Subject: Transactions not being handled properly in Stateless Session bean
s with CMT
Hi,
I am developing some stateless session beans, in which the beans' methods
are performing some database operations (insert, update directly and also
through stored procedures).
Beans are declared CMT and all methods in all the beans have attribute
*Required*. So, all the transactions are being handled by container.
In one of the bean, one of the method is getting a collection of Object
type, say ABC, getting iterator on it, and then using the while loop on this
iterator saving (inserting) all the objects in database.
In some cases (for testing purpose) the collection comes with two or more
records with same primary key. In this case, an SQL exception should be
thrown and the transaction should be rolled back.
Here's what's happening actually: SQL Exception is thrown, but rollback(ing)
is not being done. what ever records were inserted before this exception
occurred (in the while loop) get committed.
What may be the problem in the above case? As SQL exception is not an
application exception (or is it not considered a system exception?),
container should have set Rollback true. Do I need to use setRollbackOnly in
case of non-Application exceptions and errors also?
The same is happening in case of calling stored procedures also. Even if an
SQL exception comes after returning from stored procedure, what ever is done
in the stored procedure gets committed.
Env:
Weblogic v6.0 with sp2
OS: Win 2K
DB: MSSQL server 2000
I'm using Transactional Data Source, with two phase commit.
Any insight comments to this problem would be greatly appreciated.
Thanks,
- Hement
===========================================================================
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".
This e-mail and any files transmitted with it are for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient, please contact the sender by reply e-mail and
destroy all copies of the original message.
Any unauthorised review, use, disclosure, dissemination, forwarding, printing or
copying of this email or any action taken in reliance on this e-mail is strictly
prohibited and may be unlawful.
Visit us at http://www.cognizant.com