【问题标题】:RequestFactory and @OneToMany associationRequestFactory 和 @OneToMany 关联
【发布时间】:2012-04-20 03:41:16
【问题描述】:

我被困在这里了!任何帮助将不胜感激。

我的情况是我的模块上有一个@OneToMany 关联。

 class Parent{
    @OneToMany(
       mappedBy="parent"
    )
    return List<Child> getChildren();
 }

 class Child{
   @ManyToOne
   return Parent getParent();
 }

我想在客户端获取整个对象映射。

我这样做(以 DataGrid 作为显示的 AsyncDataProvider):

 requestContext.getParents().with("children").fire(new Receiver<CallbackProxy>() {
                @Override
                public void onSuccess(CallbackProxy response) {
                    display.setRowData(range.getStart(),response.getParents());
                    updateRowCount(response.getCount().intValue(), true);
                }
            });

我的 DAO 只是查询整个地图。

 Criteria criteria = session.createCriteria(Parent.class);
 criteria.setFetchMode("children", FetchMode.JOIN);
 criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

 /* we got all the map here on the server side */       

 Callback callback = new Callback();
 callback.setCount(count);
 callback.setParents(criteria.list());

 return callback;

但我不能得到孩子。它们的列表为空。请注意我使用 with("children")

谢谢。

【问题讨论】:

  • 我的问题是我将结果包装到 ValueProxy 中,似乎 with("") 在结果代理中查找属性。

标签: gwt jpa requestfactory


【解决方案1】:

RequestContext.getParents() 似乎返回 CallbackProxy 但不返回父级。所以 with 子句应该看起来像“parents.childs”。

顺便说一句,为什么不称他们为“孩子”?只是为了这种情况,GWT 家伙有一天会添加一个语法检查器 :-)

【讨论】:

  • 呵呵 ;) 我只是使用随机名称作为示例。对不起
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-09-19
  • 2013-08-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-10
  • 1970-01-01
相关资源
最近更新 更多