• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

DB.unlock() vs. RecordNotFoundException

 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 221
Scala Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 11604
    178
    Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
    Gift giving made easy with the permaculture playing cards
    https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    reply
      Bookmark Topic Watch Topic
    • New Topic