I'm having the following problem when using GWT and request factory.
I am working on an object tree that is composed of different entities, say A references B and C, C references D.
I have a loadAs method that return the whole object graph using the with annotations (with("B", "C", "C.D")
). So far everything looks great and i have the following structure loaded on the client.
A1
-> B1
-> C1
-> D1
Now I create the following within a request context on the client.
A* (created on the client using context.create() )
-> B1 (same B1 that was already loaded)
-> C* (created on the client using context.create())
-> D1 (same D1 that was already loaded)
My persist Method looks like this: Request<List<A>> persistAs(List<A>)
I fire it with the exact same with-parameters as loadAs (with("B", "C", "C.D")
) but still my response looks like this:
A* (now contains an id that was created on the server)
-> B1 (same as the previously loaded)
-> C* (now contains an id that was created on the server)
-> null
So, the D1 that already exists on the client is not part of the response's object tree. However, D1 is sent to the server and available in the persistAs method as part of the requests object tree. In addition, persistAs makes sure that the full object tree is returned (D1 is contained).
I have no clue why this happens. I also don't know where to debug. I don't get any exception.
Additional information or findings that I noticed while debugging and trying to nail this down:
For testing purposes i modified my server implementation of the persistAs method so that it internally calls loadAs after the As have been persisted. But then the client receives nothing at all?!? See the following code example for illustration:
List<A> persistAs(List<A> As) {
//Persist the As
// Make sure the object graph of the As is loaded
// return As;
// Debug only - return As using loadAs -> the client receives nothing at all
return loadAs(As);
}
I suppose (I fear) it might be a weird consequence of http://code.google.com/p/google-web-toolkit/issues/detail?id=7189
Try edit()
ing your D1 proxy (and B1 too, as you're at it) before you fire()
the RequestContext
.