This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm also working on B&S assigment. And yes, there is "findByCriteria" method.
So, my business search method first calls Data.findByCriteria, than reads all records this method returned and displays records with exact matches only...
SCJP<br />SCJD (B&S in progress)
Joined: Nov 06, 2005
So am I to take it for example when you are creating the entire tablemodel for all the records...your business method calls the read method a whole bunch of times? The read method is I think specified in the DB file of B&S.
author and jackaroo
I assume that this method replaces the find() method that is in my copy of the B&S assignment:So - back to Michael's question / comment:
Which would mean in my opinion that the findByCriteria method of the Data class will be practically useless. Am I right?
Do you also have the comment "Field n in the database file is described by criteria[n]" (see my code snippet)?
I think what we have here is another case where Sun's instructions require interpretation (Sun have indicated that there are places where they have deliberately left confusing instructions just to force candidates to show that they can get through them).
So, while the sentence you picked out, and the words you highlighted, make it appear that the findByCriteria() method (and the find() method in my case) are going to return far too much, the earlier sentence indicates (to me) that a better interpretation would be: "A non-null value in criteria[n] matches any record where field[n]'s value begins with criteria[n]."
And I have a sentese in The User Interface specification: "It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user."
In the DB schema, name is first field and location is second field.
Therefore, can i call find method like : String criteria = new String; criteria="fred"; criteria="adel";
int returnResult = DBImp.find(criteria);
and result will have int array of record numbers matching the value in name field( i.e both of "fred" and "freddy") and/or match the value in location (i.e both of "adel" and "adelaide")
Am i right?
another question is about "AND/OR" in "where the name AND/OR location fields exactly match values specified by the user."
I have no idea how i can make code "name and location" and "name or location". if i pass the criteria array value below
String criteria = new String; criteria="fred"; criteria="adel"; criteria="and"; or criteria="or";