When we say Transactions in EJB take care of complete transactionality. Let's assume that I wiriting stateless session bean ,
If I open a connection with database and I insert record in the database table and commits the data.
After commiting record insertion using database connection, Transaction moves forward for doing other things.
If LATER Exception occurs and transaction rollbacks , Will the INSERTED record will be rollbacked?.
Regards
Anant Patil
-
Transactions in Session Bean (7 messages)
- Posted by: Anant Patil
- Posted on: July 18 2003 06:46 EDT
Threaded Messages (7)
- Transactions in Session Bean by Paul Strack on July 18 2003 09:49 EDT
- Mastering EJB by Sean Sullivan on July 20 2003 11:47 EDT
- Transactions in Session Bean by Venkatesh Rajmendram on July 20 2003 12:01 EDT
- Datsource and EJB transactions by Anant Patil on July 21 2003 07:03 EDT
- Transactions in Session Bean by Raffi Basmajian on July 21 2003 16:57 EDT
- Transactions in Session Bean by Venkatesh Rajmendram on July 22 2003 11:56 EDT
- Transaction in SSB by supraja madhavi on July 22 2003 06:54 EDT
-
Transactions in Session Bean[ Go to top ]
- Posted by: Paul Strack
- Posted on: July 18 2003 09:49 EDT
- in response to Anant Patil
If you are using EJB, you should never manually commit or rollback data. You must let the EJB server manage your commits and rollbacks. If you try to do your own commits, you will likely get ugly errors. If you want to manually flag a rollback, you should use SessionContext.setRollbackOnly() rather than Connection.rollback(). -
Mastering EJB[ Go to top ]
- Posted by: Sean Sullivan
- Posted on: July 20 2003 11:47 EDT
- in response to Anant Patil
Download a copy of Ed Roman's Mastering EJB.
He discusses EJB transactions in his book.
https://www.theserverside.com/books/masteringEJB/index.jsp -
Transactions in Session Bean[ Go to top ]
- Posted by: Venkatesh Rajmendram
- Posted on: July 20 2003 12:01 EDT
- in response to Anant Patil
It depends, Say suppose your Stateless ejb calls a DAO and which calls a stored procedure(SP) say on DB2 and assume SP is written in Cobol. So when the SP is called there is no control since the call is triggred. If the transcation continues with other things and execption occurs ahead, then may be you cannot rollback the operation of SP. -
Datsource and EJB transactions[ Go to top ]
- Posted by: Anant Patil
- Posted on: July 21 2003 07:03 EDT
- in response to Venkatesh Rajmendram
Hi Venkatesh,
You have mentioned one possibility where transaction will not rollback insertion , Great.
But in Session Bean(may be using DAO) If we are making JDBC connection with any RDBMS using DataSource provided by Appserver. Will XA Data source automatically talk to EJB transactions in Rollback case, Even if the program have commited the insertion.
Thanks and reagrds
Anant Patil -
Transactions in Session Bean[ Go to top ]
- Posted by: Raffi Basmajian
- Posted on: July 21 2003 16:57 EDT
- in response to Venkatesh Rajmendram
A stored procedure written in COBOL has no way to notify the caller if an error occurs? If a SSB calls a DAO, which calls the database to invoke a stored proc, your application will know if anything goes wrong with the store procedure since the database is required to throw an exception if it cannot successfully commit the procedure. I don't think the language with which the procedure was written matters, but if this is the case with COBOL, hell, I would never use it.
Raffi -
Transactions in Session Bean[ Go to top ]
- Posted by: Venkatesh Rajmendram
- Posted on: July 22 2003 23:56 EDT
- in response to Raffi Basmajian
All the stored procedures return some sort of return code, which you can use to figure out weather its operation was successful or not, even it does happen in COBOL.
Well I guess we were discussing here the situation when the SP is done and transcation gives exception ahead due to someother reason. So during that time you cannot rollback your transcation, Since SP has already done its job in legacy environment. -
Transaction in SSB[ Go to top ]
- Posted by: supraja madhavi
- Posted on: July 22 2003 06:54 EDT
- in response to Anant Patil
After inserting and commiting record will be commited in database.
Once the exception occurs through SSB/DAO the transaction willl be definetly rolled back.