Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Record locking from a EJB session bean

Record locking from a EJB session bean

From: Don Chambers <dchamber_at_mindspring.com>
Date: Sun, 11 Mar 2001 08:50:42 -0500
Message-ID: <8tumat021c1rkedo5nbtguie651h8593gg@4ax.com>

I have a Stateless Session bean running on a WebLogic server that accesses an Oracle 8.1.6 database using the Oracle JDBC Thin Client driver. I would like some suggestion for recording locking. By record locking I do not mean locking records during an update transaction until the commit. I mean ensuring that two users are not updating the same record and they loose data.

In the past I have used the 'For Update' clause of the select statement. I have also read about using setTransactionIsolation() to set the isolation level I don't think these methods will work with a Stateless Bean. Is it possible for a transaction to span multiple sessions?

I have planned to code it manually but I think there must be a better way. My plan was to return a last_updated DateTime when data is selected for editing. When the data is saved I'll return this DateTime and make sure it is still the same in the record. If it is I'll update the data and set the last_updated value to the new time.

I need to select data and lock the record. The stateless bean sesson begins with this select and ends when the data is returned. When the updated data needs to be saved a new session bean is invoked to update the database. If the record was locked by the first seesion bean then it will still be locked when the second bean updates the data (or the lock would have been released when the first bean ended).

I am considering changing to a stateful bean but am concerned with performance. This system will using the conenction pool and will have hundreds of concurrent users. If each call is stateful and I must wait for user entry I could have hundreds of active beans (all with a database connection) active at one time.

When creating EJB applications many common issues such as security and transaction management can be handled at deployment time. I would think that there must be a simplier way to handle such a common problem as record locking.

Any input would be greatly appreciated.

Thanks,

   Don Received on Sun Mar 11 2001 - 07:50:42 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US