NutzCN Logo
问答 自定义sql取值问题
发布于 42天前 作者 qq_d6c9c504 79 次浏览 复制 上一个帖子 下一个帖子
标签:
Sql sql = Sqls.create("select sum(money) as money from applet_search_meal where appletId=@appletId and opAt>=@opAt and status=2");
		sql.setParam("appletId", appletId).setParam("opAt", opAt);
		appletSearchMealService.dao().execute(sql);
		double total = sql.getDouble();
2017-10-13 14:06:19,001 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - SELECT * FROM applet_config 
2017-10-13 14:06:19,059 org.nutz.dao.impl.sql.run.NutDaoExecutor.printSQL(NutDaoExecutor.java:388) DEBUG - select sum(money) as money from applet_search_meal where appletId=? and opAt>=? and status=2
    |                  1 |          2 |
    |--------------------|------------|
    | wx0526af5c48e985e5 | 1507824000 |
  For example:> "select sum(money) as money from applet_search_meal where appletId='wx0526af5c48e985e5' and opAt>=1507824000 and status=2"
2017-10-13 14:06:19,062 cn.wizzer.common.processor.LogTimeProcessor.process(LogTimeProcessor.java:26) DEBUG - [GET ]URI=/nutzwk/private/applet/meal/pay 116ms
2017-10-13 14:06:19,063 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) WARN  - Error@/private/applet/meal/pay :
java.lang.NullPointerException
	at org.nutz.dao.impl.sql.NutStatement.getDouble(NutStatement.java:156)
	at cn.wizzer.modules.back.applet.controllers.AppletMealPayController.index(AppletMealPayController.java:60)
	at cn.wizzer.modules.back.applet.controllers.AppletMealPayController$FM$index$6052d1be34a69ad8029c9896542e7052.invoke(AppletMealPayController.java)

能查出值,但是取就不行,请教下

3 回复

要设置回调

Sql sql = Sqls.fetchDouble(...)

// 或者 

sql.setCallback(Sqls.callback.doubleValue());

太粗心了,谢谢兽总

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