From 184cc233557c189072aece29954093fedf6ac1a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=80=E6=BA=90=E6=B5=B7=E5=93=A5?= Date: Sat, 8 Jul 2023 18:13:53 +0800 Subject: [PATCH] feat: add BaseMapper.insertSelectiveWithPk() method --- .../main/java/com/mybatisflex/core/BaseMapper.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java index 5393dbef..c3be373f 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/BaseMapper.java @@ -85,10 +85,21 @@ public interface BaseMapper { /** * 插入带有主键的实体类。 * - * @param entity 实体类 + * @param entity 实体类,不忽略 {@code null} 值 * @return 受影响的行数 */ default int insertWithPk(T entity) { + return insertWithPk(entity, false); + } + + + /** + * 插入带有主键的实体类。 + * + * @param entity 实体类,忽略 {@code null} 值 + * @return 受影响的行数 + */ + default int insertSelectiveWithPk(T entity) { return insertWithPk(entity, true); }