ibatis多值异常

2012CSDN博客之星评选正式上线     2000元大奖征异构开发博文      Q14年互联网产品进化史  

        异常:Error: executeQueryForObject returned too many results. 解决方法       

        分类:            Java基础 847人阅读 评论(0) 收藏 举报

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 cn.trymore.srjy.daoImpl.PositionDaoImpl.getAuthorization(PositionDaoImpl.java:55)
at cn.trymore.srjy.serviceImpl.PositionServiceImpl.getAuthorization(PositionServiceImpl.java:51)
at cn.trymore.srjy.action.PositionAction.storeAuthorization(PositionAction.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at cn.trymore.srjy.util.AuthorityInterceptor.intercept(AuthorityInterceptor.java:28)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)

。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

QueryForObject方法返回的是一个对象,如果有多个对象的话,就会报异常。
如果有多条返回结果,不应该用executeQueryForObject,应该用executeForObjectList。
returned too many results说的是返回的值多于一个了,executeQueryForObject要求只返回一个值。

你可能感兴趣的:(java基础)