ArrayList允许添加null值,就容易造成了list内的对象转换出现java.lang.NullPointerException异常. 场景: 数据库 select min(id) as id,min(name) as name from user where 1=2; 查询出的不是没有记录,而是一条 null,null这样的记录,导致User对象为null List<User> users = useDao.find(xxx); //size=1,All elements are n…
当配置mybatis返回int类型时 select id="getUserIdByName" parameterType="string" resultType="int"> SELECT id FROM user WHERE userName = #{userName} </select> 会报错如下: org.springframework.web.util.NestedServletException: Request p…
Chapter 9 Exceptions Item 57: Use exceptions only for exceptional conditions 这条item的意思就是,千万不要用exception来控制control flow的终止,比如: // Horrible abuse of exceptions. Don't ever do this! try { int i = 0; while(true) range[i++].climb(); } catch(ArrayIndexOutO…