1. java.lang.UnsupportedOperationException: A TupleBackedMap cannot be modified.
报错类似的代码:
List<HashMap<String, Object>> newMapList = new ArrayList<>();
for (int i = 0; i < mapList.size(); i++) {
Map<String, Object> one = mapList.get(i);
one.put("something",1);
//我发现当我往这个one里面添加数据的时候就会报上面的错
}
解决方案:
List<HashMap<String, Object>> newMapList = new ArrayList<>();
for (int i = 0; i < mapList.size(); i++) {
Map<String, Object> one = mapList.get(i);
HashMap<String, Object> newOne = new HashMap<>();
newOne.putAll(one);
newOne.put("something",1);
//重新定义一个新的map,把one放入到newOne里面就好了
}
2.java.lang.NullPointerException: null
下面这样如果是其它情况会返回一个null是不允许的
@Override
public List<String> moduleIdListByUserId(String userId) {
List<String> projectIdList = getProjectIdList(userId);
if (projectIdList.size()>0) {
return getModuleIdList(projectIdList);
}
return null;
}
应该改为下面这样,首先new一个,即使没有值,也返回
@Override
public List<String> moduleIdListByUserId(String userId) {
List<String> moduleIdList =new ArrayList<>();
List<String> projectIdList = getProjectIdList(userId);
if (projectIdList.size()>0) {
moduleIdList= getModuleIdList(projectIdList);
}
return moduleIdList;
}
3. mysql 把一个时间字段置NULL报错,但是结果不影响
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ‘information_schema.PROFILING.SEQ’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by