This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes A null value in criteria[n] matches any field value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "A null value in criteria[n] matches any field value" Watch "A null value in criteria[n] matches any field value" New topic
Author

A null value in criteria[n] matches any field value

Alejandro Sandoval
Greenhorn

Joined: Apr 21, 2008
Posts: 7
HI guys.

I�m a little confused with the requirements of the find() method, it says �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".)�

It means that if there is a null value in the criteria all records will be return? Because a null value matches any field value:

Criteria = {�Fred�, null, null, null, null, null} returns all records because of the nulls or it just returns records that starts with �Fred�?
Paul Murphy
Greenhorn

Joined: Jan 03, 2002
Posts: 6
Hi Alejandro

I'm not sure it you have the same sun instructions as myself, but the following was a criteria for the UI....

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

So the only fields your are required to search on are name and location.

So if you have criteria{"Fred",null} then all contractors who name begins with fred in all location will be returned.

If you have criteria{null,"Smallville"} then all contractors in location smallville will be returned.

Hope this helps


Trying is the first step towards failure!!!
Gilles Marceau
Ranch Hand

Joined: Feb 17, 2007
Posts: 78
Hello Alejandro,

I think the key is the assignement sentence "A null value in criteria[n] matches any field value". In my opinion, this statement stands for the
field[n] only. Having a null value at criteria[n] doesn't mean
the result is the whole database, it does just mean that there is no
filtering process to do on the records field[n].

Hope this help

Gilles


SCJP 1.5<br />SCJD 1.6<br />SCBCD in progress...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A null value in criteria[n] matches any field value
 
Similar Threads
Question about javadoc
URLyBird: What is "exactly match" in URLyBird?
Exact match and starts with
search spec unclear
a question about requirement, findByCriteria