Skip to content

Commit

Permalink
解决PG问题:
Browse files Browse the repository at this point in the history
1、表没有主键时空指针异常
2、从数据库查询出表和列信息后通过反射设置值时反射不对的问题
  • Loading branch information
ouyangrongtao committed Feb 24, 2022
1 parent 39b939b commit 555131e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,16 @@ private static <T> T getObject(Class<T> clazz, List<FieldMethod> fieldMethods,
Method method = filed.getMethod();
MappingField jsonField = field.getAnnotation(MappingField.class);
if (!Objects.isNull(jsonField)) {
method.invoke(rsp, map.get(jsonField.value()));
String value = jsonField.value();
Object o = map.get(value);
if (o == null) {
o = map.get(value.toUpperCase());
}
if (o == null) {
o = map.get(value.toLowerCase());
}

method.invoke(rsp, o);
}
}
return rsp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public DataModel process(DatabaseQuery query) {
.collect(Collectors.toList()));
//处理主键,表名为key,主键为值
primaryKeysCaching.put(table.getTableName(),
primaryKeys.stream().filter(i -> i.getTableName().equals(table.getTableName()))
primaryKeys.stream().filter(i -> table.getTableName().equals(i.getTableName()))
.collect(Collectors.toList()));
}
for (Table table : tables) {
Expand Down

0 comments on commit 555131e

Please sign in to comment.