| Author |
Trasaction not getting rolled back
|
Deepak Jain
Ranch Hand
Joined: Aug 05, 2006
Posts: 637
|
|
************************************************************************************************************************************* I have this below code that creates a transaction on the client side. I want addBid() and getBids() to use client transactions and hence i have marked these methods in the stateless bean with Required transactional attribiute. I have marked the stateless bean to use CMT. Before invoking the rollback() in the client there were 5 bids in the database. When the ran the client code with rollback as follows a)Start Transaction b) Invoke a business method in Stateless Bean that adds a single bid to DB , hence making it 6 bids c) Invoke a business method in Stateless Bean that gets all the bids in the table. This displays 6 bids. d) rollback transaction. e) Invoke a business method in Stateless Bean that gets all the bids in the table. This still displays 6 bids, hence confirming that the bid was added despite of a rollback. 1) What is wrong with above code?, I thougt since the transaction is rolled back, the addition of 6th bid should have been rolled back. 2) In stateless busniess methods, how can i test that the methods did run using client transaction. ************************************************************************************************************************************* Its really starting to get disappointing now, none of things are working as expected. Hours of reading is not doing any help. Here goes another one. Client code: Client invokes a remote business method on a stateless bean. client does not start any transaction. Stateless Bean: Ran the client twice. Result: 22:42:41,203 INFO [STDOUT] Before adding: Number of bids:0 22:42:41,203 INFO [STDOUT] After adding, Number of bids:1 22:42:41,203 INFO [STDOUT] After rollback, Number of bids:1 22:42:49,875 INFO [STDOUT] Before adding: Number of bids:1 22:42:49,890 INFO [STDOUT] After adding, Number of bids:2 22:42:49,890 INFO [STDOUT] After rollback, Number of bids:2 Even after a rollback, database has two records.
|
SCJP, SCWCD, SCBCD
|
 |
Deepak Jain
Ranch Hand
Joined: Aug 05, 2006
Posts: 637
|
|
|
Experts/Ranchers, Please take time and reply.
|
 |
Chaminda Amarasinghe
Ranch Hand
Joined: May 17, 2006
Posts: 402
|
|
rollbacking or comiting must not be called immediately. Try retrieve bids from db in another method after the roll backing. you should get the correct size
|
 |
 |
|
|
subject: Trasaction not getting rolled back
|
|
|