NutzCN Logo
问答 cnd 能直接在不写sql的情况下多表查询吗
发布于 2454天前 作者 wx_7lk4hgerl7vdvt2aav1n 1882 次浏览 复制 上一个帖子 下一个帖子
标签:

比如下面这个代码,service中的T是SaleActivityBo,然后能直接在cnd中根据SaleContentBo中的条件进行关联查询吗

    public void aa() {
        Cnd cnd = Cnd.NEW();
//        cnd.and("sale_activity_id", "=", "da014468cb324ee4830b55c5444d6730");
        List<SaleActivityBo> saleActivityBoList = dao().queryByJoin(SaleActivityBo.class, null, cnd);

        List<SaleContentBo> allSaleContentBoList = new ArrayList<>();
        List<SaleContentBo> saleContentBoList;
        for (SaleActivityBo saleActivityBo : saleActivityBoList) {
            saleContentBoList = saleActivityBo.getSaleContentBoList();
            allSaleContentBoList.addAll(saleContentBoList);
        }
        allSaleContentBoList = dao().fetchLinks(allSaleContentBoList, 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;
}

1 回复
添加回复
请先登陆
回到顶部