Reputation: 5384
The details of the Request
's with() implementation of RequestFactory
in GWT
is a bit unclear to me. See here for the official documentation.
Question 1:
When querying the server, RequestFactory does not automatically populate relations in the object graph. To do this, use the with() method on a request and specify the related property name as a String.
Does this mean that if the Entity
at the server uses Lazy Fetching
, the returned EntityProxy
will have all the requested objects specified in with()? It seems a bit odd to instantiate the whole object graph of the Object server side, to only send a small piece to the client.
Question 2:
Does req.with("foo").with("foo"); do the same as req.with("foo"); ?
Question 3:
Does req.with("foo").with("bar"); do the same as req.with("foo","bar"); ?
NOTE: I'm having a really hard time finding the implementation details of with() in the source code and the API doesn't help me either.
Upvotes: 0
Views: 119
Reputation: 17489
Question 1:
It probably depends on your server side implemenation.
The with
invocation will only make sure that the corresponding getter (getFoo()
) is called shortly before the RF
call returns to the client.
That's the reason why you also have to make sure to use an OpenSessionInView
pattern, otherwise you might run into NullPointeterException
s.
Question 2:
I guess the Request<T>
implements a builder pattern.
The end-result will be the same.
However I am not sure if the getter()
will be called twice or if the with
method will check if the getter is already requested.
Question 3:
Yes it's the same.
As a sidenote. You can use req.with("foo.bar")
.
On the backend this will lead to a getFoo().getBar()
call.
Upvotes: 1