Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Entitiy bean, and record locking

 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Marco
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic