The error is as follows:
Org. springframework. Dao. incorrectresultsizedataaccessexception: incorrect result size: Expected 1, actual 0
In spring javadoc, GetObject (string, object [], class) will return NULL if the result of the query is NUL
There is a difference between line 0 and nullresult.
Row 0: Select salary from user where 1 = 2
Null result: Select max (salary) from user where 1 = 2 returns NULL
Row 0 must throw an incorrectresultsizedataaccessexception exception.
The reason is as follows:
Resultsetmetadata rsmd = Rs. getmetadata ();
Int nrofcolumns = rsmd. getcolumncount (); the number of columns in resultset is returned.
If (nrofcolumns! = 1 ){
Throw new incorrectresultsizedataaccessexception (
"Expected single column but found" + nrofcolumns, 1, nrofcolumns );
}
If there are 0 rows and more than 1 row, an exception is thrown.
It is better to use queryforlist. The returned list size is 0, which is 0 rows.
Re: http://www.xml.org.cn/blog/more.asp? Name = hongrui and ID = 9521