• Post Reply Bookmark Topic Watch Topic
  • New Topic

NX: contractor - DuplicateKeyException

 
Mike Southgate
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My assignment specifies that the createRecord method throws a DuplicateKeyException but doesn't say how it's generated. I can think of 2 scenarios:
1) the contractor name and location fields together form a primary key for the file, and you're trying to add a duplicate primary key, or
2) you go to create the record but just before you do, some other thread creates a record in the spot you were going to use.
Does anyone else see this differently, and how did you deal with #2 above?
ms
 
Gareth Knowles
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike
In my assignment (URLyBird 1.1.3) I can't see how it will ever be thrown. I increment the record numbers on creation (or re-use a deleted one) and don't have anything in the spec to suggest a primary key. I could make up a primary key but don't know if I would be penalised for this, so I just intend to document that it will never be thrown.
Cheers
Gareth.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!