• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RecordNotFound Exception for isLocked

 
Jon Pengelly
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
My data access interface has the following isLocked Method specification:
public boolean isLocked(int recNo) throws RecordNotFoundException
I am confused about why this method would throw this exception. I was just going to return a false if this method was in the locking map and true if it is in the locking map and not worry about the record actually existing in the database.
Any thoughts?
 
Jacques Bosch
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jon.

It does seem quite strange. My project did not have this method.
Maybe what you can do is to returned false if the record number is not in the locking map, but if it is, before returning true, check to see if it actually still exists. Admittedly a situation like that shouldn't really occur if you have a proper locking contract, and if it's followed, but somebody might not use your classes properly.
My instructions stated:

Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.

What do yours say?
See ya.
 
Jason Mowat
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,
FWIW, this is a bit of a trick instruction:

Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.

An excerpt in my choices.txt addressed it as follows:

In the instructions, it states "...Any methods that throw recordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file...". This is not correct if interpreted literally. The unlock method throws RecordNotFoundExceptions, but you may have to specify a deleted record number if you just called the delete method, which you would have had to lock in the first place. In order to unlock the now deleted record, you would have to specify a deleted record.

It's a little off-topic of the original post question, but I thought it was worth mentioning.
Cheers,
Jason
 
Jon Pengelly
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help guys.
Jacques - Yep. My instructions have the same comment regarding the RecordNotFoundException. I think I might follow your idea and check that
the record is in locked and if not then check that it exists.
Jason - Good point regarding the case when deleting records.
Regards,
Jonathan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic