• 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: EOAndQualifier on child entity property
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOAndQualifier on child entity property


  • Subject: Re: EOAndQualifier on child entity property
  • From: Art Isbell <email@hidden>
  • Date: Fri, 18 Aug 2006 12:16:44 -1000

On Aug 18, 2006, at 11:38 AM, Yann Bizeul wrote:

SELECT t1.id FROM Location t1, LocationTag t2, Tag t3 WHERE t1.id = t2.locationId AND t2.tagId = t3.id AND (t3.tag = "tag1" OR t3.tag = "tag2") GROUP BY t1.id HAVING COUNT(t1.id) = 2

Is there a way to "map" that query so that it fits in a EOQualifier and returns Location objects ?

No. But if performance is a problem, EOF can evaluate SQL strings directly. EOUtilities.rawRowsForSQL() will fetch NSDictionaries based in the SQL string argument, but these NSDictionaries aren't Enterprise Objects, aren't cached, aren't uniqued, etc., so you lose most of the benefits of fetching rows into objects. However, you can fetch rows into objects by using a custom query (see the "Using a Custom Query" section of the EODatabaseContext class javadoc). Constructing a valid SQL string dynamically requires care particularly because "the expression must query the same attributes in the same order that Enterprise Objects Framework would if it were generating the SELECT expression dynamically". However, see below…


That is what I was afraid to do, and since I can have thousands of locations, I guess this will end in terrible performances...

If your final query results in thousands of Locations, then I question what value this query is to the user of your app. It's usually not very useful for a user to have to deal with such a large result set. The procedure that I outlined won't necessarily fetch all Locations, only those whose tags match certain values. The intermediate results might still be a load to deal with, but if you do this in a new editing context (properly locked, of course), you could discard the editing context when finished which should free any of the fetched objects that you no longer need. The performance might be acceptable. You wouldn't need many lines of code to test this approach, but this isn't included in a typical beginner's project :-)


Aloha,
Art

_______________________________________________
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: 
 >EOAndQualifier on child entity property (From: Yann Bizeul <email@hidden>)
 >Re: EOAndQualifier on child entity property (From: Sacha Michel Mallais <email@hidden>)
 >Re: EOAndQualifier on child entity property (From: Chuck Hill <email@hidden>)
 >Re: EOAndQualifier on child entity property (From: Yann Bizeul <email@hidden>)
 >Re: EOAndQualifier on child entity property (From: Art Isbell <email@hidden>)
 >Re: EOAndQualifier on child entity property (From: Yann Bizeul <email@hidden>)

  • Prev by Date: Re: EOAndQualifier on child entity property
  • Next by Date: Re: Going mad with using framework
  • Previous by thread: Re: EOAndQualifier on child entity property
  • Next by thread: Re: EOAndQualifier on child entity property
  • Index(es):
    • Date
    • Thread