Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

doubt in Stateful session beans

Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a doubt on stateful session beans.

Suppose i have a stateful session beans that inserts the information about a user in the database in 2-3 different steps (through 2-3) different functions, and finally the method with the remove annotation is called so that the bean instance is removed.

Now, when the 1st method is called, and the return goes to the client, is the information that the method 1 is supposed to insert in the database inserted or not.
I mean, which of the following happens.
1. The information corresponding to 1st method is inserted but not
committed.(i.e. atleast the sql query is fired).
2. The information corresponding to the 1st method is not inserted, but it
is kept in some sort of buffer or something, so that all the queries are
fired at once.

The 1st approach will obviously be slower and more likely to create database locks(because you have done an insert and not committed). Also, it can make your data(inserted in the 1st method) stale because there could be some other Transaction (T2) updating the same table (and the same row).

So, my contention is that 2nd approach is used(by vendors) or specified by the EJB specs.

Can someone verify that please?

Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the transaction management typ and the persistence context type you're using ?
Just the other day, I was thinking ... about this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic