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

RecordNotFoundException in each method

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Everyone,
I know that this theme was discussed early.

But i still do not understand how to implement this requirement:
My DBMain:


And i have this must option in assignment:

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


All my methods has throws RecordNotFoundException; How I can throw RecordNotFoundException from the find method?

I was try to implement it but get strange results:
This code fails with RecordNotFoundException:

Can I just write in javadoc its not necessary to unlock record after delete because it was unlocked inside delete method?

Got a deadlock here because thread starting wait and there is no way to unlock it:

Can I lock one record twice from one client? In java doc i see only "Locks a record so that it can only be updated or deleted by this client."
there is no info about locking.


Thanks for help.

 
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 Sergey,

How I can throw RecordNotFoundException from the find method?

For example when no record is matching the criteria (instead of returning an empty array or null).

Can I just write in javadoc its not necessary to unlock record after delete because it was unlocked inside delete method?

I used the search engine and someone had a similar question. Take a look here.

Kind regards,
Roel
 
Sergey Bylokhov
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What about twice locking the same record by the same client. Can i throw IllegalStateException?

Roel De Nijs wrote:Hi Sergey,

How I can throw RecordNotFoundException from the find method?

For example when no record is matching the criteria (instead of returning an empty array or null).

Can I just write in javadoc its not necessary to unlock record after delete because it was unlocked inside delete method?

I used the search engine and someone had a similar question. Take a look here.

Kind regards,
Roel




Yes i know this approach when you extend sun interface and change only signature in this interface. But SUN try to test it in this way


Strange requirement=(
 
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
Hi Sergey,

Yes, you can throw an IllegalStateException when a record is trying to lock the same record. In my solution i simply throw an IllegalStateException if a thread/client is trying to lock a record if it has already locked a record (even if he's trying to lock the same record).

I used also my own interface (extending Sun's interface) and added some methods + changed some method declarations (but it were still legal overrides) and I passed the SCJD exam (so did a whole lot of other ranchers), so I don't think it is a problem if you do it too.

Kind regards,
Roel
 
reply
    Bookmark Topic Watch Topic
  • New Topic