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). OR 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?
posted 7 years ago
What's the transaction management typ and the persistence context type you're using ?