troyzhxu / bean-searcher

🔥🔥🔥 A read-only ORM focusing on advanced query, naturally supports joined tables, and avoids DTO/VO conversion, making it possible to realize complex query in one line of code !
https://bs.zhxu.cn
Apache License 2.0
1.31k stars 148 forks source link

表过滤怎么实现 #101

Open kpub opened 3 months ago

kpub commented 3 months ago

如题,在以下的示例中,如果我只需要查询 order, user 两张表中字段的信息,怎么排除 shop 表呢?还是说需要另外建一个实体类


@SearchBean(
    tables = "order o, shop s, user u",  // 三表关联
    where = "o.shop_id = s.id and o.buyer_id = u.id",  // 关联关系
    autoMapTo = "o"  // 未被 @DbField 注解的字段都映射到 order 表
)
public class OrderVO {
    private long id;         // 订单ID   o.id
    private String orderNo;  // 订单号   o.order_no
    private long amount;     // 订单金额 o.amount
    @DbField("s.name")
    private String shop;     // 店铺名   s.name
    @DbField("u.name")
    private String buyer;    // 买家名   u.name
    // 省略 Getter Setter
}
troyzhxu commented 3 months ago

推荐另建一个实体类