• 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
solved: advanced EOF: batch fetching relationship: can't fetch certain relationships
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

solved: advanced EOF: batch fetching relationship: can't fetch certain relationships


  • Subject: solved: advanced EOF: batch fetching relationship: can't fetch certain relationships
  • From: Jonathan Rochkind <email@hidden>
  • Date: Wed, 18 Feb 2004 12:03:32 -0600

Thanks to Alexander Spohr for giving me the idea for a solution.

Switch in your own EODatabaseContext delegate right before calling batchFetchRelationship. Implement the databaseContextShouldFetchObjects delegate method, to take the EOFetchSpecification passed in, and turn _off_ "useDistinct". The batchFetchRelationship call now works, without SQL "select distinct"!

Amazingly. One would think that the EOF logic _required_ "select distinct" to work properly, or else why would it be using select distinct at all? Perhaps select distinct makes the EOF logic more efficient, but it works without it. Or perhaps it shouldn't be using it at all, and it's a useless thing. At any rate, this works, and I can now batch fetch relationships even if the destination table can not have a 'select distinct' run against it.

When I'm done, I switch back in whatever the previous EODatabaseContext delegate was, switching out my disable-select-distinct delegate.

An improvement, in case the previous delegate actually had important logic in it that we don't want to do without, would be to somehow use java.lang.reflect.Proxy to effectively simultaneously use _both_ delegates---essentially keep the existing delegate, but add my logic to disable distinct fetches on top. I may or may not tackle that problem, as I don't currently needing it, not having an existing EODatabaseContext delegate.

--Jonathan

At 7:57 PM -0600 2/17/04, Jonathan Rochkind wrote:
Okay, more fun with batchFetchRelationship, trying to optimize some code. [I have a little bit more insight on the last question after experimenting; this is a new one].

I have a bunch of objects (call em Departments), with a to-many relationship (call it toEmployees). (It's actually a flattened many-to-many, but I don't think that effects the below description).

EOF, in batch fetching a to-many relationship, whether through a numerical setting in EOModeler, or whether through EODatabaseContext.batchFetchRelationship.... in either case, it insists on using a "SELECT DISTINCT" query on the destination entity. Alas, my database, SQL Server 7, won't allow a "SELECT DISTINCT" on a table that includes columns of types 'text'. And the Employee table does.

Prefetching relationship key paths ALSO uses a "SELECT DISTINCT", so won't work with this relationship either. Whether batch fetching/faulting, whether prefetching----I can't do it, I get an exception from my db "Can't select distinct on a table with a 'text' type column ".

Argh. So... what the heck can I do to efficiently fetch these to-many arrays? I've got a list of potentially dozens (or even 100 or 200) Departments, and I'm going to have to display them with their employees. I don't want a seperate trip to the db to resolve each Departments toEmployees relationship. Can anyone think of any alternatives at all, anything I can do to solve this problem?

--Jonathan
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: solved: advanced EOF: batch fetching relationship: can't fetch certain relationships
      • From: arturo <email@hidden>
References: 
 >advanced EOF: batch fetching relationship: can't fetch certain relationships (From: Jonathan Rochkind <email@hidden>)

  • Prev by Date: Re: [Hints] Publishing Web Service through secure HTTP (SSL)
  • Next by Date: Re: advanced EOF: batch fetching relationship: can't fetch certain relationships
  • Previous by thread: Re: advanced EOF: batch fetching relationship: can't fetch certain relationships
  • Next by thread: Re: solved: advanced EOF: batch fetching relationship: can't fetch certain relationships
  • Index(es):
    • Date
    • Thread