• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: Should I lock the database when createRecord?

 
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
the instruction doesn't tell us to lock the database file when creating a record, but it is a kind of operation to modify the databse, it should be locked, am I right, need your help.
Regards, Damu
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But what should be locked? The update() and delete() methods modify a record, and require that you lock that record before calling those methods. But for create(), the record doesn't even exist yet, so what do you lock?
You may well need to do something to prevent problems in case another thread tries to read/update/delete the record while it's still being created, or tries to create another new record. (Make sure both records don't get the same record number, for example.) Probably you will find that some sort of synchonization is helpful. But beware that it won't (can't) work the same as locking of records, because the record you;d need to lock doesn't exist yet. So you'll have to think about how to handle this problem in your code...
 
Bigwood Liu
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, thank you Jim
reply
    Bookmark Topic Watch Topic
  • New Topic