• 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

Update Issue

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:

While I was writing my choices.txt I found out that I did not think about an issue. Is it possible for someone to book a room after it was reserver by someone else? I mean if the room has already been reserved by someone else, is it possible to book it for another client?. At first I thought this was not possible but what happen when two persons have open the GUI in two different machines one performs an update over a row, meantime the other guy in the other GUI tries to update the same row (the GUI will let him try because he is not aware that someone else already booked it) do I let him update it, or should I see first if the row has not been updated already and in case that it is to tell him that another person already booked the room and say him thanks for trying.

This is a common issue with databases that I remember is called shadowing, but the point is, are we able to update twice or more times the owner ID ?.


I hope you can help me on this.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there, I thought about this issue too especially the network mode. One thing is how you designed your Data class. I did mine as a singleton so only one instance. The way I'm thinking is once one client update a record, the program/thread notifies all other threads/clients and refresh their table views.

This sounds easy but where to trigger the notification (server or Data class?)

Another way is depending on how you implement your book method. I use a JDialog popup. So I can lock the record when the JDialog opens until it disposes itself. But then the locking would be longer than usual and could have problems if program hangs during the update.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure, another customer might try to book a reserved record but should not be able to do so. My understanding is that a booked record should have the owner field populated. So it should not be possible for a customer to book a record when the owner field is populated.
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My instructions said: If record is marked deleted, it(Data-class) should throw RecordNotFoundException. Record is marked deleted, when someone has reverved it. (after that you can show user some dialog etc)
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's probably better not to allow re-booking of the same record, especially without the user knowing that he's overwriting his colleague booking. You can either entirely deny re-booking of a booked record, or at least issue a warning "This room is already booked. Are you sure you want to re-book it?". I chose the first approach.

Jari Timonen wrote:My instructions said: If record is marked deleted, it(Data-class) should throw RecordNotFoundException. Record is marked deleted, when someone has reverved it. (after that you can show user some dialog etc)


I don't believe that your instructions say "a booked record should be marked as deleted". This would be quite wrong in my opinion. Since deleted records are available for reuse (or at least that's what the javadoc probably says), anybody could overwrite a booked record (create one on top of it), and nobody will ever know there was a booked room, where, and for which client. Also, deleted record are not showable in the table, so nobody will be able to view booked rooms for (let's say) tomorrow, when the hotel wants to know how many customers to expect.
 
Ulises Pulido
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all the people that helped me in this issue,

I am going to follow the approach of checking first if the Field owner id of the row to be updated is not already filled with something after locking that row, I mean lock it first, verify, update in case nothing is in the owner field or throw an exception in case that it contains data already, unlock the row.

Also following Alecsandru advice, send to the user a message in case that he couldn't update the row because it was either deleted or already updated.

Thanks for all your comments they helped me a lot.
 
Jari Timonen
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Alecsandru Cocarla wrote:It's probably better not to allow re-booking of the same record, especially without the user knowing that he's overwriting his colleague booking. You can either entirely deny re-booking of a booked record, or at least issue a warning "This room is already booked. Are you sure you want to re-book it?". I chose the first approach.

Jari Timonen wrote:My instructions said: If record is marked deleted, it(Data-class) should throw RecordNotFoundException. Record is marked deleted, when someone has reverved it. (after that you can show user some dialog etc)


I don't believe that your instructions say "a booked record should be marked as deleted". This would be quite wrong in my opinion. Since deleted records are available for reuse (or at least that's what the javadoc probably says), anybody could overwrite a booked record (create one on top of it), and nobody will ever know there was a booked room, where, and for which client. Also, deleted record are not showable in the table, so nobody will be able to view booked rooms for (let's say) tomorrow, when the hotel wants to know how many customers to expect.



That's true. Sorry about the confusion!
reply
    Bookmark Topic Watch Topic
  • New Topic