Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

RecordNotFoundException in unlock method in Data class

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,
Due some problems with assignments upload. I have a few additional days=)))

My DBMain interface have signature for unlock method


My Data class implement DBMain interface. And in Data implementation I do not throw RecordNotFoundException because its not necessary and I describe it in me choices.txt.
But i have a questions Should I change signature in the Data class to



Or should I set it the same DBMain.



Thanks for help.
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Sergey!

Should I change signature in the Data class to



Or should I set it the same DBMain.



You can keep the first format. The important thing is to implement the DBMain interface.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sergey,

For every method implementation you just need a valid method override. So the 1st signature and 2nd signature are valid overrides, so it really makes no difference which one you use. Because you should always develop against an interface instead of an implementation (and so you must catch the RNFE although your implementation class won't throw it).

And in Data implementation I do not throw RecordNotFoundException because its not necessary and I describe it in me choices.txt.

Nice I did exactly the same, I even went a little bit further. In my own custom interface (which extends DBMain) I override the unlock-method (without the throws clause). The advantage: I didn't had to catch the RNFE (which is never thrown).

Kind regards,
Roel
 
I think I'll just lie down here for a second. And ponder this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic