hi: I have a question about how the ejb lock a record for a user. In HF EJB page 301, I understood that when a client call on a bean, the container lock the record in the DB, so that no one else can access it except the EJB container. My question is, is that record locked for the client who asked for the record bean? if so, then no other clients can even view the record. What will happen if few client are searching the DB. Are these records going to be locked to individual clients?!! It doesn't make sense to me, and I appreciate any explination on how the locking actually works, and how can different clients search, view and update the records at the same time. Thanks [ July 22, 2004: Message edited by: Hanna Habashy ]
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
Just recently we learnt that the Container only *asks* the db for locking. If the database driver doesn't support record locking, this doesn't happen. This was the case of Oracle9i and the driver we were running at our office (the good news are that Oracle is smart enough to manage by itself concurrency and that a new driver that supports record locking is coming out).
In any case, there are many kinds of locking. Exclusive locking, non-exclusive locking. In few words, the container will ask for a record to be locked for updating operation (as this would preserve the state that in the meantime, through ejbLoad, the Container will have assigned to the entity). If a record cannot be written, no matter how many clients will access it, the state of the bean will remain in synch with the db, thus the 'Container main job' for CMP has been fulfilled.