• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Trasaction not getting rolled back

 
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*************************************************************************************************************************************
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.
 
Deepak Jain
Ranch Hand
Posts: 637
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Experts/Ranchers, Please take time and reply.
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
passwords must contain 14 characters, a number, punctuation, a small bird, a bit of cheese and a tiny ad.
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic