Search code examples
javagwtrequestfactory

Request factory - load referenced entities of referenced entities


With request factory you have do define, which enbedded entities should be loaded. This is done by the "with"-keyword. For example if i load an article and i also want the collection of comments stored in the "comments" field, i have to use the following syntax:

ArticleRequest request = requestFactory.articleRequest();
request.findArticleById(1).with("comments");

This works fine. But now i also want to load an Entity stored in the "Comment"-Objects. So every comment references a "User"-entity. If i load my article and comments with the syntax shown above, all "user"-fields are set to "null". How can i tell the request factory to also load sub sub entities?


Solution

  • This should work provided there is a getUser() field in the comment interface:

    ArticleRequest request = requestFactory.articleRequest();
    request.findArticleById(1).with("comments.user");