• 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: Fetch Specifications and boolean values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fetch Specifications and boolean values


  • Subject: Re: Fetch Specifications and boolean values
  • From: Chuck Hill <email@hidden>
  • Date: Fri, 21 Apr 2006 19:50:41 -0700


On Apr 21, 2006, at 7:20 PM, Art Isbell wrote:

On Apr 21, 2006, at 4:03 PM, Daniel DeCovnick wrote:

I THINK 1 is working. It's generating what looks like valid SQL at least:
SELECT customerID FROM CUSTOMER WHERE hasShipped = ? AND customerID = customerID ORDER BY creationTime asc

Isn't hasShipped a QueueSpot property? If so, the above SQL is invalid.


Agreed, that does not look valid. It would be valid if the FROM was QueueSpot not Customer.


Hmm... I think I may be misinterpreting the nature of fetch requests then. Given a particular customer, I want to get an array of all their queuespots which have shipped. Something I could call like:

Ah. I misunderstood what you were trying to do. I thought you wanted to find Customers with shipped orders. Mea culpa.


NSArray history = customer.shippingHistory();
or
NSArray history = shippingHistory(session().defaultEditingContext());
whichever's appropriate.

NSArray history = EOUtilities.objectsWithQualifierFormat(session ().defaultEditingContext(), "QueueSpot", "customer = $@ and hasShipped = $@", new NSArray(new Object[] {customer, Boolean.TRUE)});

Art's got it. In EOModeler this would go on the QueueSpot entity not on Customer as it is fetching QueueSport objects, not customer objects.


As an alternative implementation, you could do this in memory and place it in the Customer class:

/** @TypeInfo QueueSpot */
public NSArray shippingHistory() {
EOQualifier shippedQualifier = EOQualfier. qualifierWithQualifierFormat("hasShipped = $@", new NSArray (Boolean.TRUE));
return EOQualifier.filteredArrayWithQualifier(queueSpots(), shippedQualifier);
}


If most / all of the QueueSpots are already in memory, this should be faster. If most / all are in the database, the fetch will be quicker. Using prefetching keypaths or batch faulting can ensure that the QueueSpots are in memory, but at extra processing and memory cost. This is not warranted if they are seldom needed. It is an excellent optimization if they are.

Yes, there are a lot of choices and much to consider in selecting the best approach for a given situation. :-)

Chuck


--
Coming in late 2006 - an introduction to web applications using WebObjects and Xcode http://www.global-village.net/wointro


Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems. http://www.global-village.net/products/practical_webobjects




_______________________________________________ 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: 
 >Fetch Specifications and boolean values (From: Daniel DeCovnick <email@hidden>)
 >Re: Fetch Specifications and boolean values (From: Chuck Hill <email@hidden>)
 >Re: Fetch Specifications and boolean values (From: Daniel DeCovnick <email@hidden>)
 >Re: Fetch Specifications and boolean values (From: Chuck Hill <email@hidden>)
 >Re: Fetch Specifications and boolean values (From: Daniel DeCovnick <email@hidden>)
 >Re: Fetch Specifications and boolean values (From: Art Isbell <email@hidden>)

  • Prev by Date: Re: Fetch Specifications and boolean values
  • Next by Date: Re: Beginners question: three-tier app with cocoa client
  • Previous by thread: Re: Fetch Specifications and boolean values
  • Next by thread: WOHyperlink and bindings
  • Index(es):
    • Date
    • Thread