Re: Using distinct in to-many relationship?
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 16:41:49 -0700
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.
How are you determining that you are getting duplicate objects in
the prefetched to-many relationships? I suspect that your bug lies
elsewhere.
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
_______________________________________________
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