activejdbc递归地包含父级

时间:2016-04-14 19:50:26

标签: activejdbc

我正在使用activejdbc和:

我有3个模特:城市属于国家属于国家,好吗?我这样做:

Paginator p = new Paginator(City.class,count,filters).orderBy(orderParams); LazyList page = p.getPage(pag).include(State.class);

这会加载城市的状态(我做page.toMaps()),

现在我想加载国家

可能吗?

1 个答案:

答案 0 :(得分:0)

include()方法仅依赖于一个级别向上或向下。这意味着如果您从CIty级别开始,则只能获得状态。如果你想同时获得两者,你可以从这样的状态开始:

Paginator p = new Paginator(State.class, count, filters) 
                                       .orderBy(orderParams); 
LazyList page = p.getPage(pag).include(City.class, Country.class);

不确定这对你有用。这是一个没有Paginator的例子: http://javalite.io/lazy_and_eager#eager-simultaneous-loading-of-parents-and-children