Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

findByCriteria --- and --- or

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Peter Yunguang Qiu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Search two times, there will be the same result, no other case.
It must be "and" .
Best,
 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic