Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Question regarding lock in SCJD  RSS feed

 
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...
 
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!