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

B&S: find() and locking records for reterival

 
Musab Al-Rawi
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Find() in the DBMain interface returns int[]... as users we are interested in the actual records not the record numbers of course... so the algorethim would be something like this:
1. in the business layer the user invokes search()
2. search() invokes find() and get int[]
3. search() starts reterieving recrods returned from find()

here is the problem: WHAT IF the CPU decides that another thread should run after step 2, and that thread is changing one of the records (for example changing the name of the contractor) that happen to be returned by find().
the user issued the search might end up with record(s) that don't match his/her criteria.

Ideas ?

Thanks
 
Jar Jaquiso
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Musab,

The same problem was discussed at this post, give it a look.

To resume, the idea is to re-validate each record when you retrieve it after the find() method.

Jar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic