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

[NX Contractor] How to update without error

 
George Fung
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 methods in Db.java.
1. int[] find(String[]) that returns a list of recordNo
2. update(recNo, lockCookie)
When user search, server return a list of records.. Ok..let's say user A want to update record 5. Before user A lock and updates it, user B have already updated. How can we prevent it?
One of solns is to lock the records b4 server return the list. Then, we assure the records are not updated by others.. But it seems ridiculous
.User may be idle several mins b4 going to update.
Any other soln to solve it?
 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO, you don't need to lock any records unless they're being updated. The find method does not need to lock the recs. The records are listed whether or not they're locked. It's only when the user selects one to update it that the record should be locked.
ms
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George,
I agree with Mike - you don't need to lock records until just before you do your update.
When you try and comit your user's requested booking, you should lock the record, then verify that it is still available for booking, book it, then unlock it.
As long as you do that verification, it does not matter if someone else has booked the record since you did your search and retrieval.
Regards, Andrew
 
George Fung
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There may be the following case:
User A search 1st..and go to hv lunch..
User B change the cost of contractor, name, location,etc on a record (update)..
User A come back and book it, but he don't knwo the record is already updated by others... Then, he book wrong contractor...
So, how to prevent it?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George
This may be outside of requirements. But I did handle it. In the booking method, I didn't just check that the one field was still OK for booking - I also compared all the other fields. If they changed then I displayed a warning for the clients.
Regards, Andrew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic