EntityBuilder优化

This commit is contained in:
redkale
2024-01-06 21:37:23 +08:00
parent a7f1ef2c3b
commit 8c5b8b0a70

View File

@@ -296,11 +296,17 @@ public class EntityBuilder<T> {
obj = creator.create();
for (String sqlCol : sqlColumns) {
Attribute<T, Serializable> attr = attrs.get(sqlCol);
boolean sqlFlag = false;
if (attr == null && sqlCol.indexOf('_') > -1) {
attr = attrs.get(snakeCaseColumn(sqlCol));
sqlFlag = true;
}
if (attr != null) { //兼容返回的字段不存在类中
attr.set(obj, getFieldValue(attr, row, 0));
if (sqlFlag) {
attr.set(obj, getFieldValue(row, sqlCol));
} else {
attr.set(obj, getFieldValue(attr, row, 0));
}
}
}
} else {