|
@@ -15,11 +15,10 @@
|
|
*/
|
|
*/
|
|
package com.baomidou.mybatisplus.core.handlers;
|
|
package com.baomidou.mybatisplus.core.handlers;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Constants;
|
|
import org.apache.ibatis.reflection.MetaObject;
|
|
import org.apache.ibatis.reflection.MetaObject;
|
|
import org.apache.ibatis.reflection.SystemMetaObject;
|
|
import org.apache.ibatis.reflection.SystemMetaObject;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Constants;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 元对象字段填充控制器抽象类,实现公共字段自动写入
|
|
* 元对象字段填充控制器抽象类,实现公共字段自动写入
|
|
@@ -57,7 +56,7 @@ public interface MetaObjectHandler {
|
|
* @param metaObject meta object parameter
|
|
* @param metaObject meta object parameter
|
|
*/
|
|
*/
|
|
default MetaObjectHandler setFieldValByName(String fieldName, Object fieldVal, MetaObject metaObject) {
|
|
default MetaObjectHandler setFieldValByName(String fieldName, Object fieldVal, MetaObject metaObject) {
|
|
- if (metaObject.hasSetter(fieldName)) {
|
|
|
|
|
|
+ if (metaObject.hasSetter(fieldName) && metaObject.hasGetter(fieldName)) {
|
|
metaObject.setValue(fieldName, fieldVal);
|
|
metaObject.setValue(fieldName, fieldVal);
|
|
} else if (metaObject.hasGetter(Constants.ENTITY)) {
|
|
} else if (metaObject.hasGetter(Constants.ENTITY)) {
|
|
Object et = metaObject.getValue(Constants.ENTITY);
|
|
Object et = metaObject.getValue(Constants.ENTITY);
|