A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
One : About book sequence
I'v looked someone use book sequence like this:
lock -- read -- update -- unlock.
But in my design, I don't need to use read method, I use 3 tier design and use a business method book to do this. The book sequence is : when the use enter one cusId and press "book" button, my view class can construct a Record object and pass it to the model class, the model class then get the informations of this record instance and call business method book() to finish this sequence. So my sequence is :
lock -- update -- unlock.
I don't need to read, because the record is construct in client. Whether I miss something here ?
Two : About find method of Data
On the find() method of DBMain that sun support interface, the statement like this:
So I think this method's search mechanism is case-sensitive. Because the statement is "Fred" matches "Fred" or "Freddy, not "Fred" matches "Fred" or "Freddy or "freddy". In my design, search mechanism is case-insensitive defaultly, this means that this find method isn't fit me. So I create another method findByCondition() method and use it in my application. I implements find() method but don't use it at all. Whether this break SUN's requirements? And what do you think and solution on this?
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Since the only field that can be updated is owner id, thus, I think the data string can be composd in the client side, as it is the only difference of the data, and there is NO unbook function.
Jacques<br />*******<br />MCP, SCJP, SCJD, SCWCD
My checking is based on whether the record is being booked, by checking whether the field "owner_id" contains anything.
The server gets a lock for record X. Before any updates, the system checks whether the owner id with the record X is empty string or not. If it is empty string, then the system updates it. Otherwise, the system throws a RecordAlreadyReservedException to the client.
Since the only field that can be updated is owner id, thus, I think the data string can be composd in the client side, as it is the only difference of the data, and there is NO unbook function.
Does this make sense?
But this doesn't allow for the future functionality of the system to be implemented. Remember you have create, update, and delete methods too that might come in to use in the future.
So, let's say you don't do another read (because only the owner field is changing), and your record gets deleted right before you update/book it. What then?
The extra read is to make sure you have the latest valid info in the record.
SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Two : About find method of Data
On the find() method of DBMain that sun support interface, the statement like this:
quote:A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
So I think this method's search mechanism is case-sensitive. Because the statement is "Fred" matches "Fred" or "Freddy, not "Fred" matches "Fred" or "Freddy or "freddy". In my design, search mechanism is case-insensitive defaultly, this means that this find method isn't fit me. So I create another method findByCondition() method and use it in my application. I implements find() method but don't use it at all. Whether this break SUN's requirements? And what do you think and solution on this?
Pls comments, thanx?
Originally posted by Leo Tien:
Hi Philippe:
Because I want to supply a Flexible search mechanism, like my assignment said -- "A data access system that provides record locking and a flexible search mechanism"; So I support case-insensitive search and use it in default.
In GUI, I support a checkbox named "case-sensitive" like Ken's solution.
Make sense?
1-> Find exact matches. Ex: "Fred" matches "Fred". Do not match "Freddy",
"Fredo", "fred", "freddy".(This is the "User Interface" requirement)
2-> Other search is as this. Ex: "Fred" matches "Freddy", "Fredo", "Fred",
"fred", "fredo". Do not match "free", "freeze" like that.(This is the
additional function we are providing, right?)
Originally posted by Leo Tien:
Hi Satish:
Thank you reply.
So my solution is :
1. By default, "Fred" will match "Fred", "Freddy", "freddy" and so on. This is base on "flexible search" and "start with" statement in the assignment.
Sounds good to me and as a matter of fact I am doing the same.
2. When the use select "Exact" check box only, "Fred" will match "Fred" and "fred" only.
If you can document that "Exact" is case-insensitive, then I think it should be fine. Because, when we say "Exact", its "Exact", that's what I think. Here my implementation would be "Fred" only matches with "Fred", but not "fred".
3. When the use select "Case-sensitive" check box only, "Fread" will match "Fred", "Freddy" ....
4. When 2 and 3, "Fred" only match "Fred", this is equals "exact match" in assignment.
This is OK.
I don't know whether this solution have some problem. Pls comments.
Thanx.
The solution as I said, looks perfect![]()
2. If user de-selects it then: "Fred" matches "fred", "freddy", "Fredo".
For example, "Fred" matches "Fred" or "Freddy".)
Especially if you use comboboxes to present possible field values to the user. In case there is a "fRed" and a "Fred" in the databases, they would appear as separate entries in the combos anyway, right? But maybe you don't use comboboxes...
Originally posted by Leo Tien:
Hi Satish:
May be you are right.
My question is which find() did you use ? The find() that given by sun or your owns like my design.
I used a different method than Sun's. But I implemented it.
If you use suns, do you believe that method should support case-insensitive?
No. They exclusively specified "Fred" matches with "Fred", "Freddy". We cannot assume case insensitive there. More over I have only one find method which performs all sort of search depending on the condition.
Because the statement on it like this:
I think this method is case-sensitive, what do you think??
Its Case-sensitive that's what I think. Fred does'nt match fred there.
Thanx.
Originally posted by Leo Tien:
Hi Philippe:
If there's "fRed", "Fred", "fReddy" and "Freddy" in the databases, then when the user select "Fred", in flexible mode, which of these record will be shown??
Pls comments, thanx and waiting...
Originally posted by Leo Tien:
Hi Philippe:
Now my book method is like this:
It seems that you are hiding the class variable data(of type Data) with local variable data(of type String[]). I was confused at first of how you are comparing String object with that of Data(I assumed at first that data is only Data type) in the for loop. As I was reading "Code Conventions", I came through a line "Avoid local declarations that hide declarations at higher levels". Its just for your information as there is potential for confusion here. You may stick with what you have already done.
Pls comments.
I don't use any synch in this method because I use lock mechanism, it's right ? Whether I should write this sequence(if someone want use update() API, he must use this sequence) in my choise document??
Waiting your help,![]()
[ March 03, 2004: Message edited by: Leo Tien ]
Originally posted by Leo Tien:
Hi Philippe:
Now my book method is like this:
code:
this.data.lock(recNo);
String[] readRecord = this.data.read(recNo);
if ( !readRecord[readRecord.length].equals("") ) {
throw new RecordNotFoundException("This record is booked already !");
}
for ( int i = 0; i < readRecord.length - 1; i++ ) {
if ( !readRecord[i].equals(data[i]) ) {
throw new RecordNotFoundException("This record is modified already !");
}
}
this.data.update(recNo, data);
this.data.unlock(recNo);
Pls comments.
I don't use any synch in this method because I use lock mechanism, it's right ? Whether I should write this sequence(if someone want use update() API, he must use this sequence) in my choise document??
Waiting your help,![]()
I don't use any synch in this method because I use lock mechanism, it's right ?
It seems that you are hiding the class variable data(of type Data) with local variable data(of type String[]). I was confused at first of how you are comparing String object with that of Data(I assumed at first that data is only Data type) in the for loop. As I was reading "Code Conventions", I came through a line "Avoid local declarations that hide declarations at higher levels". Its just for your information as there is potential for confusion here. You may stick with what you have already done.
1. As you couldn't reasonably book a modified record (even in the case owner is still blank), I wouldn't perform the first test.
2. Even if you keep it, I wouldn't bet as you do that the owner field will stay the last one in the record, forever.
3. RecordNotFoundException is an exception declared in the db package for very specific uses in the db context. Is it a good idea to reuse it in the business layer?
Originally posted by Leo Tien:
Hi Satish:
Thanx for your reply.
I don't do any db cache in my design. I think it will let us to do much more works. In my design, every user can use "search" mechanism to get the newest record information of the db. But when these information is display on the client, I don't ensure that these information is same as in the db file. So when the user want to book one record, I must check whether this record is valid, in other words, perhaps the records that user have seen have been deleted or modified.
I don't know whether this design miss some requirement of the assignment, but I really don't see any statemnt on the assignment to must do synch(db cache) on the db.
Pls comments. Thanx.
Hi Philippe:
quote: 1. As you couldn't reasonably book a modified record (even in the case owner is still blank), I wouldn't perform the first test.
Whether you said that one record could be booked again? If I don't check it, when the record have been booked and the owner field haven't been empty, then you can book it again. Am I right, pls comments?
Yes, I will get owner field index in the string array first in my real code, but it must know the owner field name, is this way right ?
Yes, Yes
. I'm sorry first, because I don't say the code above is only my test code. In real code, I will construct RecordHaveBookedException in 1 and RecordHaveModifiedException in 2.
In my opinion, the user shouldn't even have the opportunity at the GUI level to book a already booked room. That's why I think it's enough to just check that the record didn't change between the time the user got it (as a result of a search for instance) and the time he tries to book it.
If this, I have a confuse here. Let's look this condition: when two client want to book one record at the same time, they want to lock the record at first, but client 1 get it and lock it and client 2 must wait. Then client 1 do read, book and unlock at last, now client 2 get the record lock and out waiting pool and do read, book and unlock too. I think if you don't check whether this record is booked, in other words the owner field is empty, then client 2 will cover client 1.
Consider Paul's rocket mass heater. |