Thursday, December 29, 2011

Re: Serializing and Deserializing EntityProxy with created EntityProxy inside makes root EntityProxy have created EntityProxy's stableId

Simple case in case my wording was a little confusing:

TestRootProxy rootProxy =
requestContext.create(TestRootProxy.class); //Doesn't matter if it's a
loaded one or an unpersisted root
DefaultProxyStore store = new DefaultProxyStore();
ProxySerializer serializer = requestFactory.getSerializer(store);
String id = serializer.serialize(rootProxy);
String data = store.encode();
PersonProxy item =
requestContext = requestFactory.testRootRequest();"Root stableId: " +
EntityProxyCategory.stableId(AutoBeanUtils.getAutoBean(item))); //This
will print out the same stable id as below."Child stableId: " +
item = requestContext.edit(item);
item.getChild(); //This will throw a classcastexception as child is
overwritten now to be pointing to the TestRootProxy.

On Dec 29, 10:45 am, Kevin Jordan <> wrote:
> I'm trying to preserve a modified EntityProxy's state between user
> session by using the ProxyStore to serialize it and deserialize it,
> but it appears that if it has a reference EntityProxy in a field
> inside, the root proxy's stableId gets overriden with the one of the
> created EntityProxy.  This leads to it getting replaced incorrectly on
> a .edit() of it such that everything gets set to the root proxy when
> it goes to clone it.  I believe the problem lies with how it does the
> operations here:
> @Override
>   <Q extends BaseProxy> AutoBean<Q>
> getProxyForReturnPayloadGraph(SimpleProxyId<Q> id) {
>     AutoBean<Q> toReturn = super.getProxyForReturnPayloadGraph(id);
>     if (restored.add(id)) {
>       /*
>        * If we haven't seen the id before, use the data in the
> OperationMessage
>        * to repopulate the properties of the canonical bean for this
> id.
>        */
>       OperationMessage op =
> getOperation(getRequestFactory().getHistoryToken(id));
>       this.processReturnOperation(id, op);
>       toReturn.setTag(Constants.STABLE_ID, super.getId(op));
>     }
>     return toReturn;
>   }
> Although I'm not exactly sure why it gets the wrong id set.  They also
> seem to have perfectly good stable ids set before it gets to the
> setTag function too, so I'm not sure why it's necessary to do that.
> I'd also tried doing it manually via AutoBeanCodex, but it seems I'd
> have to force a lot of stuff including stable ids and frozen statuses
> into the proxies that way.  Has anyone had any luck with serializing
> and deserializing EntityProxies with un-persisted proxies inside the
> root proxy?

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment