query查询多层次一对多关系, 再将首层SaleActivityBo和第二层SaleContentBo、EffectiveAreaBo查出来之后,第三层的SaleRuleBo是否必须for循环第二层的saleContentBoList然后才能查询出来第三层的值,有没有其他的方式,for数据库效率太低
public void aa() {
List<SaleActivityBo> saleActivityBoList = dao().query(SaleActivityBo.class, null);
System.out.println(saleActivityBoList);
saleActivityBoList = dao().fetchLinks(saleActivityBoList, null);
System.out.println(saleActivityBoList);
for (SaleActivityBo saleActivityBo : saleActivityBoList) {
List<SaleContentBo> saleContentBoList = saleActivityBo.getSaleContentBoList();
saleContentBoList = dao().fetchLinks(saleContentBoList, null);
}
System.out.println(saleActivityBoList);
}
public class SaleActivityBo extends SaleActivity {
private EnumSaleActivityStatusPhase saleActivityStatusPhase;
/**
* 生效区域的集合
*/
@Many(field = "saleActivityId")
private List<EffectiveAreaBo> effectiveAreaBoList;
/**
* 优惠内容的集合
*/
@Many(field = "saleActivityId")
private List<SaleContentBo> saleContentBoList;
}
public class SaleContentBo extends SaleContent {
/**
* 保存营销规则的集合
*/
@Many(field = "saleContentId")
private List<SaleRuleBo> saleRuleBoList;
}