On 14 November 2011 08:47, Hilco Wijbenga <[email protected]> wrote:
> On 14 November 2011 06:33, Robert Quinn <[email protected]> wrote:
>> Equality works as Thomas mentioned, so one basic question leaps to
>> mind: Why are you comparing EntityProxys from different contexts or
>> with different stableIds?  Maybe there is a more centralized way you
>> could manage those EntityProxys so that you are not dispersing them in
>> various states/contexts across your app.
>
> Firstly, I should have been more concerned about hashCode when working
> with Sets but hashCode and equals go hand in hand and hashCode is part
> of EntityProxyCategory as well.
>
> The EntityProxy-s might be from different contexts but they are not
> editable and all fields (including stableId) are the same. I checked
> this. They all come from the database, through RF, so I have no
> control over how many instances are created, AFAICT.
>
> But I'm really confused now. I can see that equals/hashCode do what I
> need them to do (i.e. compare stableId) but it's not working. Very
> strange.

Okay, so Robert was spot on. The problem is with RequestContexts. The
set has a RequestContext (although I'm not sure why, AFAICT its
onSuccess method has already run) and the proxy does not (i.e.
BaseProxyCategory.requestContext(proxy) returns NULL).

I'm sure there is a good reason for the RequestContext check in
EntityProxyCategory.equals() but it seems more like a bug than a
feature to me. Because of this extra check sets and maps no longer
work as one would expect them to.

How do I remove an EntityProxy from its RequestContext? There doesn't
seem to be a close() method or similar on RequestContext. When is the
RequestContext set to NULL? How do I get sets/maps to work again?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to