Here comes a doubt for me , create throws a DuplicateKeyException when finds an identical key ,
If the key is recNo , then its to be auto-generated (probably previous max + 1) , so there is no chance of a duplicate key comes here .
I�m not sure what the requirements state for your assignment but does the key have to be the recNo?
Can you run a search for through the records for similar fields of the newly created record?
Name Name + Location Name + Location + Size
As just a few examples that could act as the DuplicateKey to check when the user has created a new record.
SCJP 1.4<br />SCJD
Alex Belisle Turcot
posted 11 years ago
you're right, it does not have to be recNo but I liked the suggestion, a lot less error prone I would think. No funny situation, update and create at the same time, updating the keys of 2 different records.. (update reuse the same recNo and create will use another one or the one from a deleted record.) [ November 08, 2007: Message edited by: Alex Belisle Turcot ]
In fact, my lock method does not allow locking on a deleted record (it throws RecordNotFound)
And, only 1 thread is allowed to create (synchronized block). So, there is no need to lock at the record-level when creating a new record. Create will either reuse a delete record or insert a new one, it's all the same since only 1 thread is allowed at once there.
Thanks for all your advice/tips/comments.
Wink, wink, nudge, nudge, say no more, it's a tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database