executeQueryForObject returned too many results

有一个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打死也不能查出多条结果啊?


慕斯709654
浏览 1425回答 2
2回答

守候你守候我

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

慕的地8271018

提示已经很清楚了。queryForObject只需要1条记录,但实际返回了多条记录。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java