Meaningless Drivel is fun!
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes doubt in Stateful session beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "doubt in Stateful session beans" Watch "doubt in Stateful session beans" New topic

doubt in Stateful session beans

Rahul Babbar
Ranch Hand

Joined: Jun 28, 2008
Posts: 210
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?


Rahul Babbar
Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
What's the transaction management typ and the persistence context type you're using ?

SCJP 5 (98%) - SCBCD 5 (98%)
I agree. Here's the link:
subject: doubt in Stateful session beans
It's not a secret anymore!