return too many result

用的是ibatIS 。。。新手求解

xml:

<select id="getInfo" resultClass="java.util.ArrayList" parameterClass="com.yourcompany.struts.form.InfoForm">

select * from uinfo

</select>

impl:

public ArrayList<InfoDO> getStudentByForm(InfoForm form) {
  ArrayList<InfoDO> info= null;
  try{
   info= (ArrayList<InfoDO>)getSqlMapClientTemplate().queryForObject("getInfo", form);
  }catch(Throwable t){
   System.out.println("throwable:");
   t.printStackTrace();
  }
  return info;
 }

action:

ArrayList<InfoDO> info= new ArrayList<InfoDO>();
  try {
         info= (ArrayList<InfoDO>)this.studentdao.getStudentByForm(stuform);
         
         request.setAttribute("infomap", info);
  } catch (Exception e) {
   e.printStackTrace();
  }

 

后台:

org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; Error: executeQueryForObject returned too many results.; nested exception is java.sql.SQLException: Error: executeQueryForObject returned too many results.

 

该怎么改?

返回一个list
改2个地方:
1.代码:
info= (ArrayList)getSqlMapClientTemplate().queryForList("getInfo", form);
2.配置文件
//映射数据列,和实体类字段



info= (ArrayList)getSqlMapClientTemplate().queryForObject("getInfo", form);
queryForObject 用于 返回一个object也就是单条数据 你这个明显是list使用 executeForObjectList
info= (ArrayList)getSqlMapClientTemplate().executeForObjectList("getInfo", form);

resultClass="java.util.ArrayList"
应该改成resultMap="InfoDO类路径.InfoDO"

select * from uinfo

resultClass应该是InfoDO

大哥我刚打错了
1.如果你希望返回一个list 那么
info= (ArrayList)getSqlMapClientTemplate().queryForObject("getInfo", form);
getSqlMapClientTemplate().queryForObject 用于 返回一个object也就是单条数据 你这个明显是list使用 queryForList
info= (ArrayList)getSqlMapClientTemplate().queryForList("getInfo", form);
2.如果希望返回一个object 那么就是

select * from uinfo