Browse Source

perf:Jdbc3KeyGenerator shared instance

dqw 4 years ago
parent
commit
53916ea761

+ 2 - 2
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/injector/methods/Insert.java

@@ -50,8 +50,8 @@ public class Insert extends AbstractMethod {
         // 表包含主键处理逻辑,如果不包含主键当普通字段处理
         if (StringUtils.isNotBlank(tableInfo.getKeyProperty())) {
             if (tableInfo.getIdType() == IdType.AUTO) {
-                /** 自增主键 */
-                keyGenerator = new Jdbc3KeyGenerator();
+                /* 自增主键 */
+                keyGenerator = Jdbc3KeyGenerator.INSTANCE;
                 keyProperty = tableInfo.getKeyProperty();
                 keyColumn = tableInfo.getKeyColumn();
             } else {

+ 1 - 1
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/injector/methods/InsertBatchSomeColumn.java

@@ -92,7 +92,7 @@ public class InsertBatchSomeColumn extends AbstractMethod {
         if (tableInfo.havePK()) {
             if (tableInfo.getIdType() == IdType.AUTO) {
                 /* 自增主键 */
-                keyGenerator = new Jdbc3KeyGenerator();
+                keyGenerator = Jdbc3KeyGenerator.INSTANCE;
                 keyProperty = tableInfo.getKeyProperty();
                 keyColumn = tableInfo.getKeyColumn();
             } else {