hi,ranchs,be glad to meet you guys here.
I have read the posts for some time so I put some questions of mine here.
My assignment is B&S and there's a function in the "DBAccess.java" interface:
//Returns an array of record numbers that match the specified
//criteria. Field n in the database file is described by
//criteria[n]. A null value in criteria[n] matches any field
//value. A non-null value in criteria[n] matches any field
//value that begins with criteria[n]. (For example, "Fred"
//matches "Fred" or "Freddy".)
public long[] findByCriteria(
String[] criteria);
Then,how to make sure that the record numbers the "findByCriteria" returns are up-to-date to client?
For example, if a client calls the "findByCriteria" and get returning {2,3,5,8}.But immediately after getting the record numbers, another client access the record "5" (just an example) and go to update it. Then how do you make sure the client GUI displays these records correctly?Because you only get record numbers,not the REAL records.
The point here is that the "findByCriteria" is a little bit misleading provided by SUN.If I were the "DBAccess.java" designer,I would like writing it as "public String[] findByCriteria(String[] criteria);" or returning a list of record objects.
We need to wrap this function with some locking mechanism if we wanna realize the "search" utility?! (I don't think client lay can directly call this function.)
Correct me if my assumption is not right.
thanks in advance