executeQueryForObject returned too many results 财富值77

2016-10-21 16:37发布

有一个SQL:

select coalesce(count(1),0) from table where searchDt=#searchDt#

ibatis Dao层是这么写的:

public Integer findCount(String searchDt) throws SQLException {     return (Integer)this.get().queryForObject("xxxxx",searchDt); }

现在提示错误:

java.sql.SQLException: Error: executeQueryForObject returned too many results.     at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:108)     at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)     at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)     at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)     at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:83)     at com.boco.monitor.dao.xxxxDao.findCount(xxxxDao.java:112)     at com.boco.monitor.service.xxxxService.xxxxAnalysis(xxxxService.java:882)     at com.boco.monitor.task.Task.run(Task.java:35)     at java.util.TimerThread.mainLoop(Timer.java:555)     at java.util.TimerThread.run(Timer.java:505)

奇了怪了,这SQL打死也不能查出多条结果啊?

3条回答

列表项目

提示已经很清楚了。queryForObject只需要1条记录,但实际返回了多条记录。

确认一下传入的参数searchDt名字和值有没有问题

一周热门 更多>