aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes findByCriteria --- and --- or 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 "findByCriteria --- and --- or" Watch "findByCriteria --- and --- or" New topic
Author

findByCriteria --- and --- or

Peter Yunguang Qiu
Ranch Hand

Joined: Nov 22, 2003
Posts: 99
I am not sure returned redcords shoulbe be match(equal) all the fields of Criteria[n](and) or match(equal)one field of criteria[n]?
could someone help me to explain?
Thanks.
Peter


Peter
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

For this assignment you can assume they are all "And". Meaning if you are search on two different fields, then for the record to be a match it must have both those fields matching the search criteria.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Peter Yunguang Qiu
Ranch Hand

Joined: Nov 22, 2003
Posts: 99
The assignment says:
It must allow the user to serach the data for all records, or for records where the name and/or location fields exactly match values specified by the user.
If findByCriteria serach by "and", when a user provide bothe name and location, I have to call bindByCriteria 2 times and provide name and location seperately?
Peter
Peter Yunguang Qiu
Ranch Hand

Joined: Nov 22, 2003
Posts: 99
if serach 2 times, it might find some duplicated records
if findByCriteria serch using "or", it will be easier when search by name and/or location. Am I right?
Peter
Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Search two times, there will be the same result, no other case.
It must be "and" .
Best,
Terry Martinson
Ranch Hand

Joined: Oct 18, 2003
Posts: 293
Peter -
You don't have to call the search 2 different times. The findByCriteria method (at least in my specs) takes a String array of criteria. So, you would be sending both your name and location criteria into the method in one call, and the search method can then do its thing.
Hope that helps.
TJ


SCJP, SCJD, SCWCD, SCBCD
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Peter,
About the "and/or" issue in searching, I cannot tell you much more than what I wrote in this thread.
I think it should help you to find a way to avoid performing the search twice.
Best,
Phil.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: findByCriteria --- and --- or
 
Similar Threads
find method in B&S
Additional runtime exceptions in DB interface
URLyBird Question on finder ?
find method in the interface
search spec unclear