From 7110ff5cd34cea8f6628f51ea7a81ab35be0cd2f Mon Sep 17 00:00:00 2001 From: zhouhao Date: Wed, 26 Jul 2017 15:26:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=B1=9E=E6=80=A7copy?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/commons/entity/factory/MapperEntityFactory.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java index 7a0ffe2a9..403ccc09c 100644 --- a/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java +++ b/hsweb-commons/hsweb-commons-entity/src/main/java/org/hswebframework/web/commons/entity/factory/MapperEntityFactory.java @@ -19,6 +19,7 @@ package org.hswebframework.web.commons.entity.factory; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import org.hswebframework.web.NotFoundException; import org.hswebframework.utils.ClassUtils; import org.slf4j.Logger; @@ -80,6 +81,10 @@ public class MapperEntityFactory implements EntityFactory { PropertyCopier copier = copierCache.get(getCopierCacheKey(source.getClass(), target.getClass())); if (null != copier) return copier.copyProperties(source, target); + Object sourcePar = JSON.toJSON(source); + if (sourcePar instanceof JSONObject) { + return ((JSONObject) sourcePar).toJavaObject((Class) target.getClass()); + } return JSON.parseObject(JSON.toJSONString(source), (Class) target.getClass()); } catch (Exception e) { logger.warn("copy properties error", e);