• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

find(String[] criteria)

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please, help me with this confuse sentence:
A null value in criteria[n] matches any field.
My doubt is if I send a null value at any possition it does mean that I'm going to have all records included in my return array.

I'm a bit confused !

Tks,
Tony





 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created a small method that compares two arrays according to the findByCriteria(String[]) specification.

I compare field by field, if one criterium is null, then assume the comparison is true. If the criterium is non-null then I compare them using the String.startsWith() method.

If all the field comparisons are true (either because the criterium is null or the criterium matches the field), then I add the field number into the long[] required by the findByCriteria() method..

Therefore If I pass an criteria[] that just contains nulll valuse I would get all the records back. On the other hand, I just provide one criterium in the criteria[] and not even one record matches, then the method findByCriteria should return an empty array.
[ July 31, 2006: Message edited by: Edwin Dalorzo ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic