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

AND or OR in findByCriteria

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since the criteria come as an array, the matching is based on each element of the array, so these elements are "AND" or "OR"ed? I guess it implies "AND" op? Any suggestion?


Thanks
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it means AND too.
Probably doesn't hurt to document this interpretation though.
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Based on my assignment, I am using AND. I have B&S and it wouldn't make much sense to search for a contractor by "speciality" OR "location". A more practical search would make use of AND.

Whatever you choose, as long as you document your reasons, you should be fine.
 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is wise to follow the documentations stated by the DBAccess interface for the method. For my case, the documentation of the DBAccess interface for the findByCriteria method cannot be used for my search function based on my name and location field. What I did was to provide a separate method to be used for the search function based on name and location fields and implemented the findByCriteria method according to the specs.

I guess it is better to implement the methods of that the Data class inherits from the DBAccess interface according to the specs. If they can't be used, just don't use them, create other methods that suit your function needs. I guess after all the rules is not violated when you implemented the methods but don't use them rite?
[ September 09, 2004: Message edited by: Clivant Yeo ]
 
Andy Zhu
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all your comments. I try to summarize your points:

1. in data.java, findByCriteria will be implemented as an "AND" operation on the input array. But it is better to document this in the documentation.

2. in the client-side for search, I haven't take a close of it. so I don't have a word to say.
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Clivant Yeo:
I think it is wise to follow the documentations stated by the DBAccess interface for the method. For my case, the documentation of the DBAccess interface for the findByCriteria method cannot be used for my search function based on my name and location field. What I did was to provide a separate method to be used for the search function based on name and location fields and implemented the findByCriteria method according to the specs.

I guess it is better to implement the methods of that the Data class inherits from the DBAccess interface according to the specs. If they can't be used, just don't use them, create other methods that suit your function needs. I guess after all the rules is not violated when you implemented the methods but don't use them rite?

[ September 09, 2004: Message edited by: Clivant Yeo ]



There are two ways to do the business find method that rely on the DBAccess find method:

1) use the DBAccess find method to get the record numbers of all partial matches. The required records will be a subset of this. In your business logic, read these records and filter out the ones you want.

2) define the findByCriteria method to do a partial match padding the data with binary zeros to the length of the provided key. If you do this the string "Fred\0" will match Fred, but not Freddy.

The AND match can then be done directly using the DBAccess interface. If you want to do the OR match you get the set that match the name and the set that matches the location and do a union on the sets.

Regardless of how you do the matching, you probably should refilter the data before displaying it in the client as it may have changed between your find and read.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic