• 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: Using distinct in to-many relationship?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using distinct in to-many relationship?


  • Subject: Re: Using distinct in to-many relationship?
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 21 Aug 2006 17:19:04 -0700


On Aug 21, 2006, at 5:15 PM, Marcos Trejo Munguia wrote:


On Aug 21, 2006, at 6:41 PM, Chuck Hill wrote:


On Aug 21, 2006, at 4:21 PM, Marcos Trejo Munguia wrote:

Actually I,m using the EOFetchSpecification constructor that pass that parameter:

public EOFetchSpecification(String entityName,
                            EOQualifier qualifier,
                            NSArray sortOrderings,
                            boolean usesDistinct,
                            boolean isDeep,
                            NSDictionary hints)

I,m passing true in usesDistinct, I suppose that it have the same effect as setUsesDistinct(true). The problem is not with the main entity but with the relationships passed in setPrefetchingRelationshipKeyPaths, more specifically with to- many relationships.\

I am wondering if you are mis-understanding something. The distinct setting only applies to the objects that the fetch spec returns. The objects returned don't include the pre-fetched objects. Those are just fetched and cached, accessible by navigating relationships. The objects that the fetch returns are only those of entityName specified by qualifier.

I've discovered that today, also I've discovered that pre-fetched objects in to-one relationships are fetched using DISTINCT and to- many relationships don't. I know this because I'm debugging the generated SQL. My model looks like this:


A <<-> B <->> C

I do the fetch of A, and pre-fetch of B and C, I'm getting duplicates of C.

You may be fetching duplicates of C but EOF should not be creating duplicate objects. The fetching of duplicate rows is possibly a performance issue but should not affect the EO space.



How are you determining that you are getting duplicate objects in the prefetched to-many relationships? I suspect that your bug lies elsewhere.

I ran the generated SQL directly in my db console, there is where I saw that I was getting duplicates.

It may be worth considering batch faulting as an alternative to prefetching.


Chuck



On Aug 21, 2006, at 1:41 PM, Zak Burke wrote:

Marcos Trejo Munguia wrote on 8/21/06 2:17 PM:
Recently I found that the SQL generated by a fetch using
setPrefetchingRelationshipKeyPaths with a to-many relationship generates
the query without distinct while for to-one relationships uses distinct.

Call setUsesDistinct(true) on your fetch-spec.

I just discovered this too. It was the source of some very mysterious
seeming behaviour -- extra copies of EOs would show up in lists with
(seemingly) no explanation.


From the javadoc:

public void setUsesDistinct(boolean usesDistinct) Sets whether duplicate objects or records are removed after fetching. If flag is true they are removed (that is, proper sets are returned). If flag is false they aren't (multisets are returned). EOFetchSpecifications by default don't use distinct.

zak.


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net


This email sent to email@hidden

--

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






--

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


  • Follow-Ups:
    • Re: Using distinct in to-many relationship?
      • From: Marcos Trejo Munguia <email@hidden>
References: 
 >Using distinct in to-many relationship? (From: Marcos Trejo Munguia <email@hidden>)
 >Re: Using distinct in to-many relationship? (From: Zak Burke <email@hidden>)
 >Re: Using distinct in to-many relationship? (From: Marcos Trejo Munguia <email@hidden>)
 >Re: Using distinct in to-many relationship? (From: Chuck Hill <email@hidden>)
 >Re: Using distinct in to-many relationship? (From: Marcos Trejo Munguia <email@hidden>)

  • Prev by Date: Re: Using distinct in to-many relationship?
  • Next by Date: Re: XCode 2.3 --> XCode 2.4 [and WebObjects 5.3.2]
  • Previous by thread: Re: Using distinct in to-many relationship?
  • Next by thread: Re: Using distinct in to-many relationship?
  • Index(es):
    • Date
    • Thread