• 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
Re: Problem searching with an EOOrQualifier
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem searching with an EOOrQualifier


  • Subject: Re: Problem searching with an EOOrQualifier
  • From: Mark Morris <email@hidden>
  • Date: Sun, 5 Feb 2006 12:10:11 -0600

Hello Franco,

This is actually a SQL issue.  You can't do a standard join (an "inner join") on two tables and get results where there are no records on either side of the join (in this case, where there are no Book records).  What's needed in this case is called an "outer join".

You can specify that you're using an outer join when you define the relationship in EOModeler.

If you don't want to mess with your relationships, one idea you could think about:  You could just do 2 searches, one on Books and one on Authors.  You could do some set manipulation if you'd like to see which Authors are in the "Author" search that didn't come up in the "Book" search.

Good luck!

Regards,
Marl

On Feb 5, 2006, at 6:23 AM, Borgo Franco wrote:

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

References: 
 >Problem searching with an EOOrQualifier (From: Borgo Franco <email@hidden>)

  • Prev by Date: Re: Long delay after Application.java
  • Next by Date: Re: Help: How to use WOPopupButton
  • Previous by thread: Problem searching with an EOOrQualifier
  • Next by thread: D2WQuery Help.... Anyone?
  • Index(es):
    • Date
    • Thread