NutzCN Logo
问答 dao.func2好坑.....
发布于 2592天前 作者 蛋蛋的忧伤 1889 次浏览 复制 上一个帖子 下一个帖子
标签:

我用dao.func2执行数据库内置函数,然后出现了极其神奇的事情.........
代码如下:

/**
     * 给代理加总金额
     * @param users
     * @param agent
     */
    public void addAgentWallet(List<UserAccount> users,Agent agent){
        for (int j = 0; j < users.size(); j++) {
            Object sum = dao().func2(Order.TABLE_NAME, "sum", Order.TOTAL_PRICE, Cnd.where(Order.USER_ACCOUNT, "=", users.get(j).getAccount()).and(Order.OSTATUS,"=", OrderConfig.SUCCESS));
            if(sum == null){
                sum = 0;
            }
            BigDecimal bigDecimal = new BigDecimal(String.valueOf(sum));
            agent.setWallet(agent.getWallet().add(bigDecimal));
            System.out.println(agent.getWallet().toString());
        }
    }

我dao.func2哪一行执行后有时候是null,有时候有值,我断点跟 了之后发现sql放到工具里执行是有值的但是返回的就是null,但是有时候就正常 ,好神奇.....

[DEBUG] 09:57:31.684 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT sum(total_price) FROM orderinfo  WHERE user_account=? AND ostatus=?
    |           1 |   2 |
    |-------------|-----|
    | 15065728696 | 已完成 |
  For example:> "SELECT sum(total_price) FROM orderinfo  WHERE user_account='15065728696' AND ostatus='已完成'"
5090.0
[DEBUG] 10:02:20.546 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT * FROM agent  WHERE parent_id=? AND agent_type=?
    |  1 |  2 |
    |----|----|
    | 64 | 代理 |
  For example:> "SELECT * FROM agent  WHERE parent_id=64 AND agent_type='代理'"
[DEBUG] 10:02:20.567 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT * FROM user_account  WHERE parent=?
    |           1 |
    |-------------|
    | 15615086991 |
  For example:> "SELECT * FROM user_account  WHERE parent='15615086991'"
[DEBUG] 10:02:21.235 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT * FROM user_account  WHERE parent=?
    |           1 |
    |-------------|
    | 18853547567 |
  For example:> "SELECT * FROM user_account  WHERE parent='18853547567'"
[DEBUG] 10:02:21.939 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT * FROM user_account  WHERE parent=?
    |           1 |
    |-------------|
    | 15065728696 |
  For example:> "SELECT * FROM user_account  WHERE parent='15065728696'"
[DEBUG] 10:02:23.902 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) - SELECT * FROM user_account  WHERE parent=?
    |           1 |
    |-------------|
    | 13858402662 |
  For example:> "SELECT * FROM user_account  WHERE parent='13858402662'"

我都发正式包了发现查的不对才发现这个怪问题,请问这是什么原因撒.....

3 回复

日志贴的有点问题.....日志执行的第一个sql是我dao.func2的那句......其他不是...

因为连错数据库.

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