From 9fa2d5df2f18f2d9e58538956774d2517db2d137 Mon Sep 17 00:00:00 2001 From: Ice Date: Mon, 23 Oct 2023 22:29:10 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=A4=9Alistener=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mybatisflex/core/FlexGlobalConfig.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java index 5c68ccb6..ee4ad4fe 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/FlexGlobalConfig.java @@ -221,13 +221,15 @@ public class FlexGlobalConfig { private void doGetSupportedSetListener(Class childClass, Map, SetListener> listeners) { SetListener setListener = null; + Class listenersMapKey = null; while (setListener == null && childClass != null) { setListener = entitySetListeners.get(childClass); + listenersMapKey = childClass.getSuperclass() == null ? childClass : childClass.getSuperclass(); childClass = childClass.getSuperclass(); } if (setListener != null) { - listeners.put(childClass, setListener); + listeners.put(listenersMapKey, setListener); } } @@ -264,13 +266,15 @@ public class FlexGlobalConfig { private void doGetSupportedUpdateListener(Class childClass, Map, UpdateListener> listeners) { UpdateListener updateListener = null; + Class listenersMapKey = null; while (updateListener == null && childClass != null) { updateListener = entityUpdateListeners.get(childClass); + listenersMapKey = childClass.getSuperclass() == null ? childClass : childClass.getSuperclass(); childClass = childClass.getSuperclass(); } if (updateListener != null) { - listeners.put(childClass, updateListener); + listeners.put(listenersMapKey, updateListener); } } @@ -307,13 +311,15 @@ public class FlexGlobalConfig { private void doGetSupportedInsertListener(Class childClass, Map, InsertListener> listeners) { InsertListener insertListener = null; + Class listenersMapKey = null; while (insertListener == null && childClass != null) { insertListener = entityInsertListeners.get(childClass); + listenersMapKey = childClass.getSuperclass() == null ? childClass : childClass.getSuperclass(); childClass = childClass.getSuperclass(); } if (insertListener != null) { - listeners.put(childClass, insertListener); + listeners.put(listenersMapKey, insertListener); } }