首页 > 代码库 > 关于泛型的教训

关于泛型的教训

sql查询结果我用List接收就一直报异常:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: <|### Error querying database.  Cause: java.lang.UnsupportedOperationException<|### The error may exist in ***Dao.java (best guess)<|### The error may involve ***Dao.**-Inline<|### The error occurred while setting parameters<|### SQL: *** where **=?<|### Cause: java.lang.UnsupportedOperationException

改成List<Map<String,Integer>>接收就正常了,再改成List还是异常,再泛型还是正常。

结论:泛型并不是可有可无的,能泛型就泛型,泛型能用子类不用父类!

关于泛型的教训