From 9d5233e63fa51ee81a3e4e26de1ecc6801f1a57b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E6=BA=90=E6=B5=B7=E5=93=A5?= Date: Tue, 11 Apr 2023 17:28:27 +0800 Subject: [PATCH] update docs --- docs/zh/table.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/zh/table.md b/docs/zh/table.md index 01d04d03..53fb0435 100644 --- a/docs/zh/table.md +++ b/docs/zh/table.md @@ -148,4 +148,28 @@ public class MySetListener implements SetListener { } ``` -> 注意:若 entity 的属性配置了 `typeHandler`,`typeHandler` 的执行顺序高于 `SetListener`。 \ No newline at end of file +> 注意:若 entity 的属性配置了 `typeHandler`,`typeHandler` 的执行顺序高于 `SetListener`。 + +## 全局设置 + +除了通过 `@Table` 注解去单独为某一个 Entity 设置 `onInsert`、`onUpdate`、`onSet` 监听以外,我们还可以通过全局的方式去配置, +方法如下: + +```java +MyInsertListener insertListener = new MyInsertLister(); +MyUpdateListener updateListener = new MyUpdateListener(); +MySetListener setListener = new MySetListener(); + +FlexGlobalConfig config = FlexGlobalConfig.getDefaultConfig(); + +//为 Entity1 和 Entity2 注册 insertListner +config.registerInsertListener(insertListener, Entity1.class, Entity2.class); + + +//为 Entity1 和 Entity2 注册 updateListener +config.registerUpdateListener(updateListener, Entity1.class, Entity2.class); + + +//为 Entity1 和 Entity2 注册 setListener +config.registerSetListener(setListener, Entity1.class, Entity2.class); +``` \ No newline at end of file