NutzCN Logo
问答 FieldMatcher fm = FieldMatcher.make() 不起作用
发布于 158天前 作者 zjhk 195 次浏览 复制 上一个帖子 下一个帖子
标签:
public static FieldMatcher make(String actived, String locked, boolean ignoreNull, 
                                    boolean ignoreZero, boolean ignoreDate, 
                                    boolean ignoreId,
                                    boolean ignoreName,
                                    boolean ignorePk) 

代码:

FieldMatcher fm = FieldMatcher.make("^id|order_id|status|time_end|create_time|update_time$",//actived
                //"^id|order_id|status|product_id|amount|open_id|time_end|create_time|update_time$"
                null,//locked
                false,//ignoreNull
                false,//ignoreZero
                false,//ignoreDate
                false,//ignoreId
                false,//ignoreName
                false //ignorePk
        );
        FieldFilter fff = FieldFilter.create(Order.class, fm);
        List<Order> orders4 = Daos.ext(dao, fff).query(Order.class, Cnd.where("1", "=", 1)
               // .desc("id"),
                ,dao.createPager(1, 10)
        );

日志:

2018-04-15 13:05:11,365 [http-nio-8080-exec-5] DEBUG org.nutz.dao.impl.sql.run.NutDaoExecutor - SELECT id,status,amount FROM t_order  WHERE 1=? LIMIT 0, 10 
    | 1 |
    |---|
    | 1 |
  For example:> "SELECT id,status,amount FROM t_order  WHERE 1=1 LIMIT 0, 10 "
2018-04-15 13:05:11,388 [http-nio-8080-exec-5] DEBUG com.hefupb.hefuwechatadmin.common.mvc.LogTimeProcessor - [ GET]URI=/admin/test/test6 71ms

7 回复

期望得到的sql是怎样的?

@wendal //actived
//locked
//ignoreNull
//ignoreZero
//ignoreDate
//ignoreId
//ignoreName
//ignorePk 这些是互斥的嘛?之前,过滤sql字段的时候,我都是自定义sql,昨天看到nutz框架提供了这些功能,今天就试了一下,但无论我怎么配置,都得不到我期望的结果!

@wendal 现在无论我怎么配置,但是得到的sql一直都是 For example:> "SELECT id,status,amount FROM t_order WHERE 1=1 LIMIT 0, 10 "

你期望得到的sql是什么

@wendal SELECT id, status, amount id, order_id, status, time_end FROM t_order WHERE 1=1 LIMIT 0, 10

order_id字段对应的java属性名是 order_id 还是 orderId 呢?

@wendal 是orderId !我知道问题出在哪了,谢谢!

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