Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Anton Kuzmin

Greenhorn
+ Follow
since Feb 22, 2012
Anton likes ...
Mac OS X Eclipse IDE Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anton Kuzmin

Thank you all for you help on this forum I passed. It's bad though that they don't give you the detailed scores anymore.

Also had to register in pearsonvue the fact that I took the training. Waited 2 more days and they mailed me the success kit.
If instructions do not have specific search algorithm, you have to make decisions yourself and justify them in choices.txt. Think of some use cases that may happen with client and operator working with the application and implement the business logic accordingly.
Is it possible? I wasn't informed by email but in pearsonvue I see the positive results (no detailed score though) The status is still "Taken" for both parts.
The "form" contains different types of JComponent-s that respond to different user events. I started writing my own custom code but was wondering if there is automatic way to determine if there is unsaved data on form? For starters, attached DocumentListener to support JTextField-s.
8 years ago
There are also controls that are usually used with a mouse. JSpinner, for example. So this code isn't very good choice for form-based frames and dialogs.
8 years ago
This code won't work if user is changing state with a mouse.
8 years ago
Thank you! I think you broke most of my doubts
The thing is that two operators can open up the same room record in their UI.
One changes price, clicks 'Save', records gets locked, updated, unlocked.
Then other guy decides that he wants to update 'Date available', clicks 'Save', record gets locked, updated, unlocked.
Result: Record has old price.
With optimistic locking enabled along side with current locking rules, second guy will get nice message that data has been changed while he was thinking and he needs to reload it.

I do not do logical locking at record opened for edit because it creates even more problems like whether to use lock timeout, waiting for lock for very long time.
Anayonkar Shivalkar, no, instructions don't say that but DbAccess interface has this method:
// Modifies the fields of a record. The new value for field n
// appears in data[n]. Throws SecurityException
// if the record is locked with a cookie other than lockCookie.
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException;

I know that people on this forum say it's OK to implement the interface and not use it anywhere in the application. But I am not convinced that it's what Oracle/Sun wanted.

Of course, I use locks to update the record.

Anayonkar Shivalkar wrote:

Anton Kuzmin wrote:I could use "owner" column for optimistic locking at room booking but it won't help in situations when two different people update the record.


I don't get what do you mean by this. Only one thread will get a lock on a record at a time, and if the room is booked by one thread, all other threads will get error (i.e. exception at code level) that room is already booked etc. It's as simple as that.



But in my program, people will also be able to update data like price. In this case "owner" column is not enough.


Anayonkar Shivalkar wrote:

Anton Kuzmin wrote:I want to keep necessary data separate because it's not allowed to change structure of original db file in my project.


I am curious about this. What is this necessary data? And why will it alter the structure of original db file?



I am not sure whether I am violating the rules, so I'll be short.
This necessary data is "version" column. It will make optimistic locking work.
What do you think? Is it allowed? I want to keep necessary data separate because it's not allowed to change structure of original db file in my project. I could use "owner" column for optimistic locking at room booking but it won't help in situations when two different people update the record.

Better would be to just start the whole updating process (including locking) when you have all information needed (so when CSR confirms the booking and has entered the customer id)



Since the rooms are open for booking 24 hours, the best offers will be hunted the most and that could create situation when clients can get angry with too many "this room has been booked by another person" messages. Maybe old system had this problem Unfortunately, instructions don't mention it.
Wait, then someone can lock the record for very long time and other clients will be waiting for very long time? And if yes, will they be able to cancel waiting technically? And what happens when client locks and crashes leaving record permanently locked?
Roel, thanks for raising my confidence. I was thinking of the same approach just an hour ago. I will definitely do it like that