mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 01:28:24 +08:00
fix: close #I95OW7
This commit is contained in:
parent
9356905a73
commit
2e548a621a
@ -51,7 +51,8 @@ class ModifyAttrsRecordHandler implements MethodHandler {
|
||||
return proxyMethod.invoke(self, args);
|
||||
}
|
||||
|
||||
updates.put(property, args[0]);
|
||||
//用 fw.getField().getName() 的原因是 property 可能获取的内容不正确,比如 ID 会得到的内容为 iD
|
||||
updates.put(fw == null ? property : fw.getField().getName(), args[0]);
|
||||
}
|
||||
|
||||
return proxyMethod.invoke(self, args);
|
||||
|
||||
@ -51,12 +51,12 @@ public class FieldWrapper {
|
||||
synchronized (clazz) {
|
||||
fieldWrapper = wrapperMap.get(fieldName);
|
||||
if (fieldWrapper == null) {
|
||||
Field findField = ClassUtil.getFirstField(clazz, field -> field.getName().equals(fieldName));
|
||||
Field findField = ClassUtil.getFirstField(clazz, field -> field.getName().equalsIgnoreCase(fieldName));
|
||||
if (findField == null) {
|
||||
throw new IllegalStateException("Can not find field \"" + fieldName + "\" in class: " + clazz.getName());
|
||||
}
|
||||
|
||||
String setterName = "set" + StringUtil.firstCharToUpperCase(fieldName);
|
||||
String setterName = "set" + StringUtil.firstCharToUpperCase(findField.getName());
|
||||
Method setter = ClassUtil.getFirstMethod(clazz, method ->
|
||||
method.getParameterCount() == 1
|
||||
&& Modifier.isPublic(method.getModifiers())
|
||||
@ -74,7 +74,7 @@ public class FieldWrapper {
|
||||
|
||||
fieldWrapper.setterMethod = setter;
|
||||
|
||||
String[] getterNames = new String[]{"get" + StringUtil.firstCharToUpperCase(fieldName), "is" + StringUtil.firstCharToUpperCase(fieldName)};
|
||||
String[] getterNames = new String[]{"get" + StringUtil.firstCharToUpperCase(findField.getName()), "is" + StringUtil.firstCharToUpperCase(findField.getName())};
|
||||
fieldWrapper.getterMethod = ClassUtil.getFirstMethod(clazz, method -> method.getParameterCount() == 0
|
||||
&& Modifier.isPublic(method.getModifiers())
|
||||
&& ArrayUtil.contains(getterNames, method.getName()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user