Roland Kozma

Greenhorn
+ Follow
since Nov 27, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roland Kozma

Just removed the duplicate reply. - It seems that there is no way to delete a post.

Roland

Pawel Pawlowicz wrote:That's what I am doing.
I implemented find() using AND approach. A record is added to results when and only when all fields matches the criteria.
As find() method in Sun's interface matches using startsWith() and GUI should display only records that exactly matches, I extended Sun's interface and added method findExact().
So I don't need to filter any results in GUI nor buisness layer. I also don't have to worry whether there were any modifications to the database between find() being executed and filtering.
For the GUI. I have two text fields. One for name and one for location.
If both are blank then I return all records.
If one of them is blank I return records that exactly match a criterion in the other.
If both are filled I return records that match both of the criteria exactly.

What do you think?



Hi Pawel!

Glad to see that we are on the same page. My approach almost exactly match yours, and in my opinion it should be fine. Well, we'll find out soon, because I'm going to submit my app in about 10 days.
The only difference is that I use just the original find method (which returns records using the AND approach) and then I do the filtering in the service layer for exact match when is the case.
In my GUI I have separate 'Exact match' checkbox for each field, so the user can search let's say for a name starting with something and a city which exactly match the user input. - But this flexibility is beyond the requirement.

Roland

Roel De Nijs wrote:Hi Olu,

I have another implementation:

  • return all records if all criteria are null
  • if not all criteria are null, the null criteria are ignored and the others are used to search for records: a record is a match if at least one field of the record starts with the corresponding (not-null) criterium (in a case-insensitive way)

  • But of course that's not the only valid implementation.

    Kind regards,
    Roel




    Hi Roel and everybody from here!

    You said "the null criteria are ignored". -> Why do you ignore the null criteria?

    If you consider that "A non-null value in criteria[n] matches any field value that begins with criteria[n]." means that
    any record that match at least one criteria should be returned,
    why don't you interpret the sentence "A null value in criteria[n] matches any field value." in the same way:
    If at least one null is present in the criteria, all the records from the database should be returned (because a null match any field).

    Because these seams contradictory I think that returning just the records which match all the criteria (using AND) should be a valid interpretation too.
    Have you heard that somebody failed because of this interpretation?
    Until I stumbled in this subject on the forum I had no doubt that we should use AND to match all the provided criteria.

    Regards,
    Roland