diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/AccountOnSetListener2.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/AccountOnSetListener2.java new file mode 100644 index 00000000..8af9d4c5 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/AccountOnSetListener2.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * http://www.apache.org/licenses/LICENSE-2.0 + *
+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mybatisflex.test; + +import com.mybatisflex.annotation.SetListener; + +public class AccountOnSetListener2 implements SetListener { + + @Override + public Object onSet(Object entity, String property, Object value) { + return value; + } + +} diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/AccountOnSetListener3.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/AccountOnSetListener3.java new file mode 100644 index 00000000..1f4097d4 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/AccountOnSetListener3.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *
+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *
+ * http://www.apache.org/licenses/LICENSE-2.0 + *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.mybatisflex.test;
+
+import com.mybatisflex.annotation.SetListener;
+
+public class AccountOnSetListener3 implements SetListener {
+
+ @Override
+ public Object onSet(Object entity, String property, Object value) {
+ return value;
+ }
+
+}
diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/AccountTester.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/AccountTester.java
new file mode 100644
index 00000000..4482a3d8
--- /dev/null
+++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/AccountTester.java
@@ -0,0 +1,25 @@
+package com.mybatisflex.test;
+
+import com.mybatisflex.annotation.SetListener;
+import com.mybatisflex.core.FlexGlobalConfig;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.List;
+
+/**
+ * @author 王帅
+ * @since 2024-04-12
+ */
+public class AccountTester {
+
+ @Test
+ public void testRegisterListener() {
+ FlexGlobalConfig globalConfig = FlexGlobalConfig.getDefaultConfig();
+ globalConfig.registerSetListener(new AccountOnSetListener2(), Account.class);
+ globalConfig.registerSetListener(new AccountOnSetListener3(), Account.class);
+ List