• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem searching with an EOOrQualifier
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem searching with an EOOrQualifier


  • Subject: Problem searching with an EOOrQualifier
  • From: Borgo Franco <email@hidden>
  • Date: Sun, 5 Feb 2006 07:23:19 -0500

I have a many-to-many relationship between Author and Book.

Author <-->> AuthorBook <<--> Book

Each with a string attribute,
Name of an Autor and Title of a Book.

I want to be able to search fields on both entities.
The search string is in wordToSearch.
Searching through this mailing list, I was able to adapt this code for an "OR" search.

My Problem:
wordToSearch is "franco"

I can   find an Author name "Bob" who wrote a Book titled "Franco"
I can't find an Author name "Franco" without any book assign to him.

If I assign a Book titled "racing" to Author "Franco",
or If I remove qual2 from the EOOrQualifier then the Author entity with name "Franco" shows up.

I am new to WebObject and help would be very appreciated.
Thank you

Franco



public WOComponent goSearch()
    {
editingContext = session().defaultEditingContext();
String wordToSearch = this.motAChercher();

EOSortOrdering nameSort = new EOSortOrdering("name",EOSortOrdering.CompareCaseInsensitiveAscending);
NSMutableArray sortOrderings = new NSMutableArray();
sortOrderings.addObject(nameSort);
if (wordToSearch == null)
{
listOfAuthors = new NSArray(editingContext.objectsWithFetchSpecification(authorFetch));
}
else
{
wordToSearch =  "*" + wordToSearch + "*";
EOKeyValueQualifier qual1 = new EOKeyValueQualifier("name",
            EOQualifier.QualifierOperatorCaseInsensitiveLike,
            wordToSearch);
EOKeyValueQualifier qual2 = new EOKeyValueQualifier("books.title",
                    EOQualifier.QualifierOperatorCaseInsensitiveLike,
                    wordToSearch);

EOOrQualifier orClause = new EOOrQualifier(new NSArray (new Object[] { qual1, qual2 } ));

EOFetchSpecification wordToSearchFetchSpecification = new EOFetchSpecification("Author", orClause, sortOrderings);
listOfAuthors = new NSArray(editingContext.objectsWithFetchSpecification(wordToSearchFetchSpecification));

}
return null;
    }
   
   
    
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem searching with an EOOrQualifier
      • From: Mark Morris <email@hidden>
  • Prev by Date: Re: WOBuilder + Webkit Any Chance?
  • Next by Date: D2WQuery Help.... Anyone?
  • Previous by thread: Re: Long delay after Application.java
  • Next by thread: Re: Problem searching with an EOOrQualifier
  • Index(es):
    • Date
    • Thread