activejdbc 递归包含父级
activejdbc include parent recursively
我在使用 activejdbc 并且:
我有 3 个模型:City 属于 State 属于 Country,好吗?我这样做:
Paginator p = new Paginator(City.class, count, filters).orderBy(orderParams);
LazyList page = p.getPage(pag).include(State.class);
这会加载城市及其状态(我做 page.toMaps()),
现在我也想加载国家
可能吗?
include()
方法只对依赖关系进行向上或向下一级处理。这意味着如果您从 CIty 级别开始,您只能获得一个状态。如果你想同时获得两者,你可以像这样从状态级别开始:
Paginator p = new Paginator(State.class, count, filters)
.orderBy(orderParams);
LazyList page = p.getPage(pag).include(City.class, Country.class);
虽然不确定这是否适合您。这是一个没有分页器的例子:
http://javalite.io/lazy_and_eager#eager-simultaneous-loading-of-parents-and-children
我在使用 activejdbc 并且:
我有 3 个模型:City 属于 State 属于 Country,好吗?我这样做:
Paginator p = new Paginator(City.class, count, filters).orderBy(orderParams); LazyList page = p.getPage(pag).include(State.class);
这会加载城市及其状态(我做 page.toMaps()),
现在我也想加载国家
可能吗?
include()
方法只对依赖关系进行向上或向下一级处理。这意味着如果您从 CIty 级别开始,您只能获得一个状态。如果你想同时获得两者,你可以像这样从状态级别开始:
Paginator p = new Paginator(State.class, count, filters)
.orderBy(orderParams);
LazyList page = p.getPage(pag).include(City.class, Country.class);
虽然不确定这是否适合您。这是一个没有分页器的例子: http://javalite.io/lazy_and_eager#eager-simultaneous-loading-of-parents-and-children