Search code examples
gwtrequestfactory

GWT / RequestFactory - Object tree of response is not fully loaded although with() parameters seem ok


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:

  • when I trigger loadAs on the client after they have been persisted, the full object graph is returned
  • I am using objectify as persistency api
  • C is a supertype that is abtract in nature, it is however implemented as a normal entity and its subtypes are too, as this concept works everywhere else i can't imagine that this is the problem. To be more precise: C is always a concrete subtype. The reference from C to D however is directly on the super type C. C and all its subtypes are marked as entity proxies and have corresponding server entities.
  • 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);
    }
    

Solution

  • 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.