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

DB.unlock() vs. RecordNotFoundException

 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

the DB method unlock() specifies a RecordNotFoundException in its throws-clause,
whereas the assignment says:

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


Implementing the methods in this way, I always receive a RecordNotFoundException
when performing the following tasks in my business model:



How did you resolve this problem?

Regards,
Andy
 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andy,


I do check first for x to be in my map of locked records and also if the cookie that was passed is the same stored in my map for x,
if this is true I do remove the value in my map for x and call notifyAll().
If not if x is in my map but the cookie passed as argument is not
I throw a SecurityException.
if not I check if the record x does not exist
and if this the case I throw RecordNotFoundException.


Hope this helps,


Carlos.
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Carlos,

that's it !
Thanks for that hint, the problem was, that I firstly validated the recNo with the possible consequence of a RNFE being thrown and after that I did cookie matching. Reversing validation logic will resolve this.

Kind regards,
Andy
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andy,

In my own created interface update, delete and unlock methods don't throw the RNFE anymore, because it makes no sense at all. You have to always lock the record prior to updating/deleting/unlocking, so when record doesn't exist anymore you will get the RNFE when you lock the record. When you successfully have locked a record, it can't disappear mysteriously
This approach simplifies again my code: I don't have to catch any RNFE which will never happen. But you won't be a fan, because you are a Beckenrandschwimmer and are afraid of the automatic failure ghost ;)

Kind regards,
Roel
 
Andy Jung
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roel,

you're right, RNFE in those methods don't make much sense anymore having logical locking.
After a record is locked, a record shouldn't vanish mysteriously, except
that a mean guy accesses and manipulates the database file meanwhile or
due to some magnetic or mechanical failure the record flag on hard disk turns to an invalid one.
But that's actually a stupid "Beckenrandschwimmer" argument ;-).
You like that word, don't you ?
To improve your German further, I'll tell you some more synonyms for that, i.e. :
  • Turnbeutelvergesser
  • Warmduscher
  • Weichei

  • regards,
    Andy
     
    Roel De Nijs
    Sheriff
    Posts: 10662
    144
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Andy Jung wrote:To improve your German further, I'll tell you some more synonyms for that, i.e.
    Because in Belgium there are 3 official languages (dutch, french and german) I had to learn 4 languages (the 3 official ones + english of course). In our 1st German lesson we learnt the word "Tempotaschentucher". I never forgot that one, so funny After all Dutch and German are closely related to each other.

    Kind regards,
    Roel
     
    Andy Jung
    Ranch Hand
    Posts: 150
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Roel,

    I know, the best foreign language speakers in Europe are people from small countries like Belgium, Denmark, Holland ...
    Germans are a little bit like the English: There's actually no really need to learn a foreign language.
    This is why most Germans are pretty bad in the English language (like me).

    Kind regards,
    Andy
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic