1. 程式人生 > >com ibatis common jdbc exception NestedSQLException 今天用ibati

com ibatis common jdbc exception NestedSQLException 今天用ibati

               

Error executing query for object.  Cause: com.ibatis.common.jdbc.exception.NestedSQLException:   --- The error occurred in com/yc/ycportal/blockimp/sqlmapdao/sqlmap/ycrepliesmap.xml.  --- The error occurred while applying a result map.  --- Check the selectYcRepliesBy-AutoResultMap.  --- The error happened while setting a property on the result object.  --- Cause: net.sf.cglib.beans.BulkBeanExceptionCaused by: net.sf.cglib.beans.BulkBeanException 

去網上找了找沒有發現具體的解決方案.仔細檢查程式碼發現 這個是由於呼叫了下面這個方法

/**  * Simple convenience method to wrap the SqlMap method of the same name.  * Wraps the exception with a DaoException to isolate the SqlMap framework.  *  * @param statementName  * @param parameterObject  * @return  * @  */ protected Object executeQueryForObject(  String statementName,  Object parameterObject) {  SqlMapExecutor sqlMap = getSqlMapExecutor();  try  {   return sqlMap.queryForObject(statementName, parameterObject);  }  catch (SQLException e)  {   log.error(e.getMessage());   throw new DaoException(    "Error executing query for object.  Cause: " + e,    e);  } }

本來應該返回一個物件,但是資料庫查詢結果卻返回了多條記錄.