• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question regarding lock in SCJD

 
Luiz Reginaldo Curado
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose I have the folowing:

- Client A selects a record, the update screen is showed
- Client B selects a record, the update screen is showed
- Client A update the record (lock, update, unlock)
- Client B update the record (lock, update, unlock)

So, client B will overwrite what A had done. Is it ok to the assignment???

Please, post your suggestions. I'm very confused about that in the assignment...
 
Daniel Bryant
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Luiz,

I would have to say no to that being ok...

But how about this?

- Client A selects a record, the update screen is showed
- Client B selects a record, the update screen is showed
- Client A update the record (lock, READ RECORD, CHECK EXPECTED VALUES, update, unlock)
- Client B update the record (lock, READ RECORD, CHECK EXPECTED VALUES, update, unlock)

where the READ RECORD, CHECK EXPECTED VALUES part of the process reads the record again (which has now been locked) and compares this read with the existing data (i.e. the data you expect). If the two don't match you know that someone has updated the record before you, and you can abort the process and inform the user accordingly.

Best wishes,

Daniel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic