Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!