test: 测试 Map 传参审计打印 SQL。

This commit is contained in:
Suomm 2024-04-26 10:21:52 +08:00
parent d8c68ea59d
commit aec9953bf5

View File

@ -17,6 +17,8 @@
package com.mybatisflex.test; package com.mybatisflex.test;
import com.mybatisflex.core.MybatisFlexBootstrap; import com.mybatisflex.core.MybatisFlexBootstrap;
import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.core.audit.ConsoleMessageCollector;
import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Db; import com.mybatisflex.core.row.Db;
import com.mybatisflex.core.row.Row; import com.mybatisflex.core.row.Row;
@ -24,7 +26,6 @@ import com.mybatisflex.core.row.RowUtil;
import com.mybatisflex.core.update.UpdateWrapper; import com.mybatisflex.core.update.UpdateWrapper;
import com.mybatisflex.core.util.UpdateEntity; import com.mybatisflex.core.util.UpdateEntity;
import org.apache.ibatis.exceptions.PersistenceException; import org.apache.ibatis.exceptions.PersistenceException;
import org.apache.ibatis.logging.stdout.StdOutImpl;
import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.Configuration;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;
@ -54,10 +55,13 @@ public class DbTest {
.build(); .build();
MybatisFlexBootstrap bootstrap = MybatisFlexBootstrap.getInstance() MybatisFlexBootstrap bootstrap = MybatisFlexBootstrap.getInstance()
.setLogImpl(StdOutImpl.class) // .setLogImpl(StdOutImpl.class)
.setDataSource(dataSource) .setDataSource(dataSource)
.start(); .start();
AuditManager.setAuditEnable(true);
AuditManager.setMessageCollector(new ConsoleMessageCollector());
/* /*
* 指定当结果集中值为 null 的时候是否调用映射对象的 settermap 对象时为 put方法 * 指定当结果集中值为 null 的时候是否调用映射对象的 settermap 对象时为 put方法
* 这在依赖于 Map.keySet() null 值进行初始化时比较有用注意基本类型intboolean * 这在依赖于 Map.keySet() null 值进行初始化时比较有用注意基本类型intboolean