NutzCN Logo
问答 使用动态表名查不出数据
发布于 3217天前 作者 wukonggg 1871 次浏览 复制 上一个帖子 下一个帖子
标签:

代码

 public GeneralStat getByAllColums(String tableName, GeneralStat gs) {
        Condition cond = Cnd.where("corporationid", "=", gs.getCorpId())
            .and("kpiid", "=", gs.getKpiId())
            .and("time", "=", gs.getTime())
            .and("dimension1", "=", gs.getDimension1())
            .and("dimension2", "=", gs.getDimension2())
            .and("dimension3", "=", gs.getDimension3())
            .and("dimension4", "=", gs.getDimension4())
            .and("value", "=", gs.getValue())
            .and("flag", "=", gs.getFlag());

        try {
            TableName.set(tableName);
            return dao.fetch(GeneralStat.class, cond);
        } finally {
            TableName.clear();
        }
    }

log生成的sql

SELECT * FROM (SELECT T.*, ROWNUM RN FROM ( SELECT * FROM STAT_BASE  WHERE corporationid='0300' AND kpiid='10001' AND TIME='2016-03-02 21:07:37' AND DIMENSION1='0101' AND DIMENSION2='-1' AND DIMENSION3='-1' AND DIMENSION4='-1' AND VALUE='88' AND FLAG=0) T WHERE ROWNUM <= 1) WHERE RN > 0

通过debug生成的sql,更改time为todate函数后,可以查出来数据,但程序返回的结果却为null

3 回复

gs.getDimension2() 返回的是字符串???

@wendal 除了time是date,flag是int外,全是字符串

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