diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index e93e075b700..a4a567fa78d 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -6,6 +6,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6876](https://github.com/apache/incubator-seata/pull/6876)]support kingbase
- [[#6881](https://github.com/apache/incubator-seata/pull/6881)]support grpc
+- [[#6864](https://github.com/apache/incubator-seata/pull/6864)]support shentong database
### bugfix:
- [[#6899](https://github.com/apache/incubator-seata/pull/6899)] fix file.conf read failed after package
@@ -44,6 +45,7 @@ Thanks to these contributors for their code commits. Please report an unintended
- [arrrnold17](https://github.com/arrrnold17)
- [xjlgod](https://github.com/xjlgod)
- [PleaseGiveMeTheCoke](https://github.com/PleaseGiveMeTheCoke)
+- [dsomehan](https://github.com/dsomehan)
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 771a64ad0d7..efb5f32ae50 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -3,8 +3,10 @@
### feature:
-[[#6876](https://github.com/apache/incubator-seata/pull/6876)]支持人大金仓数据库(kingbase)
-[[#6881](https://github.com/apache/incubator-seata/pull/6881)]全链路支持grpc
+- [[#6876](https://github.com/apache/incubator-seata/pull/6876)]支持人大金仓数据库(kingbase)
+- [[#6881](https://github.com/apache/incubator-seata/pull/6881)]全链路支持grpc
+- [[#6864](https://github.com/apache/incubator-seata/pull/6864)]支持神通数据库(oscar)
+
### bugfix:
- [[#6899](https://github.com/apache/incubator-seata/pull/6899)] 修复file.conf打包后的读取
@@ -46,6 +48,7 @@
- [arrrnold17](https://github.com/arrrnold17)
- [xjlgod](https://github.com/xjlgod)
- [PleaseGiveMeTheCoke](https://github.com/PleaseGiveMeTheCoke)
+- [dsomehan](https://github.com/dsomehan)
同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
diff --git a/common/src/main/java/org/apache/seata/common/util/PageUtil.java b/common/src/main/java/org/apache/seata/common/util/PageUtil.java
index ea658a64af1..b49b10eddc4 100644
--- a/common/src/main/java/org/apache/seata/common/util/PageUtil.java
+++ b/common/src/main/java/org/apache/seata/common/util/PageUtil.java
@@ -112,6 +112,7 @@ public static String pageSql(String sourceSql, String dbType, int pageNum, int p
case "kingbase":
case "oceanbase":
case "dm":
+ case "oscar":
return LIMIT_TEMPLATE.replace(SOURCE_SQL_PLACE_HOLD, sourceSql)
.replace(LIMIT_PLACE_HOLD, String.valueOf(pageSize))
.replace(OFFSET_PLACE_HOLD, String.valueOf((pageNum - 1) * pageSize));
@@ -142,6 +143,7 @@ public static String countSql(String sourceSql, String dbType) {
case "oceanbase":
case "oracle":
case "dm":
+ case "oscar":
return sourceSql.replaceAll("(?i)(?<=select)(.*)(?=from)", " count(1) ");
case "postgresql":
case "kingbase":
@@ -185,6 +187,7 @@ public static String getTimeStartSql(String dbType, String timeColumnName) {
case "postgresql":
case "sqlserver":
case "dm":
+ case "oscar":
return " and FLOOR(" + timeColumnName + "/1000) >= ? ";
default:
throw new IllegalArgumentException("The DB type :" + dbType + " is not supported yet");
@@ -204,6 +207,7 @@ public static String getTimeEndSql(String dbType, String timeColumnName) {
case "postgresql":
case "sqlserver":
case "dm":
+ case "oscar":
return " and FLOOR(" + timeColumnName + "/1000) <= ? ";
default:
throw new IllegalArgumentException("The DB type :" + dbType + " is not supported yet");
diff --git a/common/src/test/java/org/apache/seata/common/util/PageUtilTest.java b/common/src/test/java/org/apache/seata/common/util/PageUtilTest.java
index 5fcdcfd5116..640fa037015 100644
--- a/common/src/test/java/org/apache/seata/common/util/PageUtilTest.java
+++ b/common/src/test/java/org/apache/seata/common/util/PageUtilTest.java
@@ -44,6 +44,7 @@ public void testPageSql() {
assertEquals(PageUtil.pageSql(sourceSql, "postgresql", 1, 5), mysqlTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "oceanbase", 1, 5), mysqlTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "dm", 1, 5), mysqlTargetSql);
+ assertEquals(PageUtil.pageSql(sourceSql, "oscar", 1, 5), mysqlTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "oracle", 1, 5), oracleTargetSql);
assertEquals(PageUtil.pageSql(sourceSql, "sqlserver", 1, 5), sqlserverTargetSql);
@@ -61,6 +62,7 @@ void testCountSql() {
assertEquals(PageUtil.countSql(sourceSql, "postgresql"), targetSql);
assertEquals(PageUtil.countSql(sourceSql, "oceanbase"), targetSql);
assertEquals(PageUtil.countSql(sourceSql, "dm"), targetSql);
+ assertEquals(PageUtil.countSql(sourceSql, "oscar"), targetSql);
assertEquals(PageUtil.countSql(sourceSql, "oracle"), targetSql);
assertEquals(PageUtil.countSql(sourceSql, "sqlserver"), targetSql);
diff --git a/core/src/main/java/org/apache/seata/core/constants/DBType.java b/core/src/main/java/org/apache/seata/core/constants/DBType.java
index af0e82d312a..3521e3e4545 100644
--- a/core/src/main/java/org/apache/seata/core/constants/DBType.java
+++ b/core/src/main/java/org/apache/seata/core/constants/DBType.java
@@ -192,7 +192,12 @@ public enum DBType {
/**
* PolarDB db type.
*/
- POLARDB;
+ POLARDB,
+
+ /**
+ * oscar db type.
+ */
+ OSCAR;
/**
* Valueof db type.
diff --git a/core/src/main/java/org/apache/seata/core/store/db/sql/distributed/lock/DistributedLockSqlFactory.java b/core/src/main/java/org/apache/seata/core/store/db/sql/distributed/lock/DistributedLockSqlFactory.java
index 2072d4631c5..8f589780caa 100644
--- a/core/src/main/java/org/apache/seata/core/store/db/sql/distributed/lock/DistributedLockSqlFactory.java
+++ b/core/src/main/java/org/apache/seata/core/store/db/sql/distributed/lock/DistributedLockSqlFactory.java
@@ -34,7 +34,7 @@ public class DistributedLockSqlFactory {
/**
* get the lock store sql
*
- * @param dbType the dbType, support mysql/oracle/h2/postgre/oceanbase/dm/sqlserver ...
+ * @param dbType the dbType, support mysql/oracle/h2/postgre/oceanbase/dm/sqlserver/oscar ...
* @return lock store sql
*/
public static DistributedLockSql getDistributedLogStoreSql(String dbType) {
diff --git a/core/src/main/java/org/apache/seata/core/store/db/sql/lock/LockStoreSqlFactory.java b/core/src/main/java/org/apache/seata/core/store/db/sql/lock/LockStoreSqlFactory.java
index dcf5781edc5..6fb7a61e335 100644
--- a/core/src/main/java/org/apache/seata/core/store/db/sql/lock/LockStoreSqlFactory.java
+++ b/core/src/main/java/org/apache/seata/core/store/db/sql/lock/LockStoreSqlFactory.java
@@ -34,7 +34,7 @@ public class LockStoreSqlFactory {
/**
* get the lock store sql
*
- * @param dbType the dbType, support mysql/oracle/h2/postgre/oceanbase/dm
+ * @param dbType the dbType, support mysql/oracle/h2/postgre/oceanbase/dm/oscar
* @return lock store sql
*/
public static LockStoreSql getLogStoreSql(String dbType) {
diff --git a/core/src/main/java/org/apache/seata/core/store/db/sql/lock/OscarLockStoreSql.java b/core/src/main/java/org/apache/seata/core/store/db/sql/lock/OscarLockStoreSql.java
new file mode 100644
index 00000000000..bd72749ea1f
--- /dev/null
+++ b/core/src/main/java/org/apache/seata/core/store/db/sql/lock/OscarLockStoreSql.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.seata.core.store.db.sql.lock;
+
+
+import org.apache.seata.common.loader.LoadLevel;
+
+/**
+ * the database lock store shentong sql
+ *
+ */
+@LoadLevel(name = "oscar")
+public class OscarLockStoreSql extends OracleLockStoreSql {
+}
diff --git a/core/src/main/java/org/apache/seata/core/store/db/sql/log/OscarLogStoreSqls.java b/core/src/main/java/org/apache/seata/core/store/db/sql/log/OscarLogStoreSqls.java
new file mode 100644
index 00000000000..f310e03ff2e
--- /dev/null
+++ b/core/src/main/java/org/apache/seata/core/store/db/sql/log/OscarLogStoreSqls.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.seata.core.store.db.sql.log;
+
+
+import org.apache.seata.common.loader.LoadLevel;
+
+/**
+ * Database log store oscar sql
+ */
+@LoadLevel(name = "oscar")
+public class OscarLogStoreSqls extends OracleLogStoreSqls {
+}
diff --git a/core/src/main/resources/META-INF/services/org.apache.seata.core.store.db.sql.lock.LockStoreSql b/core/src/main/resources/META-INF/services/org.apache.seata.core.store.db.sql.lock.LockStoreSql
index 375298bc638..838ee9d70f3 100644
--- a/core/src/main/resources/META-INF/services/org.apache.seata.core.store.db.sql.lock.LockStoreSql
+++ b/core/src/main/resources/META-INF/services/org.apache.seata.core.store.db.sql.lock.LockStoreSql
@@ -23,4 +23,5 @@ org.apache.seata.core.store.db.sql.lock.SqlServerLockStoreSql
org.apache.seata.core.store.db.sql.lock.MariadbLockStoreSql
org.apache.seata.core.store.db.sql.lock.PolarDBXLockStoreSql
org.apache.seata.core.store.db.sql.lock.DmLockStoreSql
-org.apache.seata.core.store.db.sql.lock.KingbaseLockStoreSql
\ No newline at end of file
+org.apache.seata.core.store.db.sql.lock.OscarLockStoreSql
+org.apache.seata.core.store.db.sql.lock.KingbaseLockStoreSql
diff --git a/core/src/main/resources/META-INF/services/org.apache.seata.core.store.db.sql.log.LogStoreSqls b/core/src/main/resources/META-INF/services/org.apache.seata.core.store.db.sql.log.LogStoreSqls
index 5eb45d22e0c..90f94d6a3e5 100644
--- a/core/src/main/resources/META-INF/services/org.apache.seata.core.store.db.sql.log.LogStoreSqls
+++ b/core/src/main/resources/META-INF/services/org.apache.seata.core.store.db.sql.log.LogStoreSqls
@@ -23,4 +23,5 @@ org.apache.seata.core.store.db.sql.log.SqlServerLogStoreSqls
org.apache.seata.core.store.db.sql.log.MariadbLogStoreSqls
org.apache.seata.core.store.db.sql.log.PolarDBXLogStoreSqls
org.apache.seata.core.store.db.sql.log.DmLogStoreSqls
-org.apache.seata.core.store.db.sql.log.KingbaseLogStoreSqls
\ No newline at end of file
+org.apache.seata.core.store.db.sql.log.OscarLogStoreSqls
+org.apache.seata.core.store.db.sql.log.KingbaseLogStoreSqls
diff --git a/core/src/test/java/org/apache/seata/core/store/db/sql/lock/LockStoreSqlFactoryTest.java b/core/src/test/java/org/apache/seata/core/store/db/sql/lock/LockStoreSqlFactoryTest.java
index 4a598bbe52a..a38f75644cb 100644
--- a/core/src/test/java/org/apache/seata/core/store/db/sql/lock/LockStoreSqlFactoryTest.java
+++ b/core/src/test/java/org/apache/seata/core/store/db/sql/lock/LockStoreSqlFactoryTest.java
@@ -40,6 +40,8 @@ public class LockStoreSqlFactoryTest {
private static LockStoreSql DM_LOCK_STORE = LockStoreSqlFactory.getLogStoreSql("dm");
+ private static LockStoreSql OSCAR_LOCK_STORE = LockStoreSqlFactory.getLogStoreSql("oscar");
+
private static String GLOBAL_TABLE = "global_table";
private static String BRANCH_TABLE = "branch_table";
@@ -379,4 +381,51 @@ public void dmLockTest() {
sql = DM_LOCK_STORE.getCheckLockableSql(BRANCH_TABLE, 3);
Assertions.assertEquals(EXPECT_CHECK_BRANCH_LOCKABLE_SQL,sql);
}
+
+
+ @Test
+ public void oscarLockTest() {
+ String sql;
+ // Get insert lock sql string.
+ sql = OSCAR_LOCK_STORE.getInsertLockSQL(GLOBAL_TABLE);
+ Assertions.assertNotNull(sql);
+ sql = OSCAR_LOCK_STORE.getInsertLockSQL(BRANCH_TABLE);
+ Assertions.assertNotNull(sql);
+
+ // Get delete lock sql string.
+ sql = OSCAR_LOCK_STORE.getDeleteLockSql(GLOBAL_TABLE);
+ Assertions.assertNotNull(sql);
+ sql = OSCAR_LOCK_STORE.getDeleteLockSql(BRANCH_TABLE);
+ Assertions.assertNotNull(sql);
+
+ // Get batch delete lock sql string.
+ sql = OSCAR_LOCK_STORE.getBatchDeleteLockSql(GLOBAL_TABLE, 3);
+ Assertions.assertEquals(EXPECT_BATCH_GLOBAL_DELETE_LOCK_SQL,sql);
+ sql = OSCAR_LOCK_STORE.getBatchDeleteLockSql(BRANCH_TABLE, 3);
+ Assertions.assertEquals(EXPECT_BATCH_BRANCH_DELETE_LOCK_SQL,sql);
+
+ // Get batch delete lock sql string.
+ sql = OSCAR_LOCK_STORE.getBatchDeleteLockSqlByBranchId(GLOBAL_TABLE);
+ Assertions.assertNotNull(sql);
+ sql = OSCAR_LOCK_STORE.getBatchDeleteLockSqlByBranchId(BRANCH_TABLE);
+ Assertions.assertNotNull(sql);
+
+ // Get batch delete lock sql string.
+ sql = OSCAR_LOCK_STORE.getBatchDeleteLockSqlByXid(GLOBAL_TABLE);
+ Assertions.assertEquals(EXPECT_BATCH_GLOBAL_DELETE_LOCK_BY_BRANCHS_SQL,sql);
+ sql = OSCAR_LOCK_STORE.getBatchDeleteLockSqlByXid(BRANCH_TABLE);
+ Assertions.assertEquals(EXPECT_BATCH_BRANCH_DELETE_LOCK_BY_BRANCHS_SQL,sql);
+
+ // Get query lock sql string.
+ sql = OSCAR_LOCK_STORE.getQueryLockSql(GLOBAL_TABLE);
+ Assertions.assertNotNull(sql);
+ sql = OSCAR_LOCK_STORE.getQueryLockSql(BRANCH_TABLE);
+ Assertions.assertNotNull(sql);
+
+ // Get check lock sql string.
+ sql = OSCAR_LOCK_STORE.getCheckLockableSql(GLOBAL_TABLE, 3);
+ Assertions.assertEquals(EXPECT_CHECK_GLOBAL_LOCKABLE_SQL,sql);
+ sql = OSCAR_LOCK_STORE.getCheckLockableSql(BRANCH_TABLE, 3);
+ Assertions.assertEquals(EXPECT_CHECK_BRANCH_LOCKABLE_SQL,sql);
+ }
}
diff --git a/core/src/test/java/org/apache/seata/core/store/db/sql/log/LogStoreSqlsFactoryTest.java b/core/src/test/java/org/apache/seata/core/store/db/sql/log/LogStoreSqlsFactoryTest.java
index f3b9421862e..45c1aa3d101 100644
--- a/core/src/test/java/org/apache/seata/core/store/db/sql/log/LogStoreSqlsFactoryTest.java
+++ b/core/src/test/java/org/apache/seata/core/store/db/sql/log/LogStoreSqlsFactoryTest.java
@@ -34,6 +34,8 @@ public class LogStoreSqlsFactoryTest {
private static LogStoreSqls dmLog = LogStoreSqlsFactory.getLogStoreSqls("dm");
+ private static LogStoreSqls oscarLog = LogStoreSqlsFactory.getLogStoreSqls("oscar");
+
private static String globalTable = "global_table";
private static String branchTable = "branch_table";
@@ -246,4 +248,38 @@ public void dmLogTest() {
sql = dmLog.getQueryBranchMax(branchTable);
Assertions.assertNotNull(sql);
}
+
+ @Test
+ public void oscarLogTest() {
+ String sql = oscarLog.getInsertGlobalTransactionSQL(globalTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getUpdateGlobalTransactionStatusSQL(globalTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getDeleteGlobalTransactionSQL(globalTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getQueryGlobalTransactionSQL(globalTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getQueryGlobalTransactionSQLByTransactionId(globalTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getQueryGlobalTransactionSQLByStatus(globalTable, "1");
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getQueryGlobalTransactionForRecoverySQL(globalTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getInsertBranchTransactionSQL(branchTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getUpdateBranchTransactionStatusSQL(branchTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getDeleteBranchTransactionByBranchIdSQL(branchTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getDeleteBranchTransactionByXId(branchTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getQueryBranchTransaction(branchTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getQueryBranchTransaction(branchTable, "1");
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getQueryGlobalMax(globalTable);
+ Assertions.assertNotNull(sql);
+ sql = oscarLog.getQueryBranchMax(branchTable);
+ Assertions.assertNotNull(sql);
+ }
}
diff --git a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/DataSourceProxy.java b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/DataSourceProxy.java
index dfab706294e..8868a0c964b 100644
--- a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/DataSourceProxy.java
+++ b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/DataSourceProxy.java
@@ -243,6 +243,8 @@ private void initResourceId() {
initSqlServerResourceId();
} else if (JdbcConstants.DM.equals(dbType)) {
initDMResourceId();
+ } else if (JdbcConstants.OSCAR.equals(dbType)) {
+ initOscarResourceId();
} else {
initDefaultResourceId();
}
@@ -321,6 +323,18 @@ private void initDMResourceId() {
}
}
+ /**
+ * init the oscar resource id
+ * jdbc:oscar://192.168.x.xx:2003/OSRDB
+ */
+ private void initOscarResourceId() {
+ if (jdbcUrl.contains("?")) {
+ resourceId = jdbcUrl.substring(0, jdbcUrl.indexOf('?')) + "/" + userName;
+ } else {
+ resourceId = jdbcUrl + "/" + userName;
+ }
+ }
+
/**
* prevent pg sql url like
* jdbc:postgresql://127.0.0.1:5432/seata?currentSchema=public
diff --git a/rm-datasource/src/main/java/org/apache/seata/rm/datasource/exec/oscar/OscarInsertExecutor.java b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/exec/oscar/OscarInsertExecutor.java
new file mode 100644
index 00000000000..1a68e7f30d2
--- /dev/null
+++ b/rm-datasource/src/main/java/org/apache/seata/rm/datasource/exec/oscar/OscarInsertExecutor.java
@@ -0,0 +1,139 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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 org.apache.seata.rm.datasource.exec.oscar;
+
+import org.apache.seata.common.loader.LoadLevel;
+import org.apache.seata.common.loader.Scope;
+import org.apache.seata.common.util.CollectionUtils;
+import org.apache.seata.rm.datasource.StatementProxy;
+import org.apache.seata.rm.datasource.exec.BaseInsertExecutor;
+import org.apache.seata.rm.datasource.exec.StatementCallback;
+import org.apache.seata.sqlparser.SQLInsertRecognizer;
+import org.apache.seata.sqlparser.SQLRecognizer;
+import org.apache.seata.sqlparser.struct.Null;
+import org.apache.seata.sqlparser.struct.Sequenceable;
+import org.apache.seata.sqlparser.struct.SqlMethodExpr;
+import org.apache.seata.sqlparser.struct.SqlSequenceExpr;
+import org.apache.seata.sqlparser.util.ColumnUtils;
+import org.apache.seata.sqlparser.util.JdbcConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * The type Oscar insert executor.
+ *
+ */
+@LoadLevel(name = JdbcConstants.OSCAR, scope = Scope.PROTOTYPE)
+public class OscarInsertExecutor extends BaseInsertExecutor implements Sequenceable {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(OscarInsertExecutor.class);
+
+ /**
+ * Instantiates a new Abstract dml base executor.
+ *
+ * @param statementProxy the statement proxy
+ * @param statementCallback the statement callback
+ * @param sqlRecognizer the sql recognizer
+ */
+ public OscarInsertExecutor(StatementProxy statementProxy, StatementCallback statementCallback,
+ SQLRecognizer sqlRecognizer) {
+ super(statementProxy, statementCallback, sqlRecognizer);
+ }
+
+ /**
+ * 1. If the insert columns are not empty and do not contain any pk columns,
+ * it means that there is no pk value in the insert rows, then all the pk values should come from auto-increment.
+ *
+ * 2. The pk value exists in insert rows. The possible situations are:
+ *
+ * - The insert columns are empty: all pk values can be obtained from insert rows
+ * - The insert columns contain at least one pk column: first obtain the existing pk value from the insert rows, and other from auto-increment
+ *
+ *
+ * @return {@link Map}<{@link String}, {@link List}<{@link Object}>>
+ * @throws SQLException the sql exception
+ */
+ @Override
+ public Map> getPkValues() throws SQLException {
+ List pkColumnNameList = getTableMeta().getPrimaryKeyOnlyName();
+ Map> pkValuesMap = new HashMap<>(pkColumnNameList.size());
+
+ // first obtain the existing pk value from the insert rows (if exists)
+ if (!containsColumns() || containsAnyPk()) {
+ pkValuesMap.putAll(getPkValuesByColumn());
+ }
+ // other from auto-increment
+ for (String columnName : pkColumnNameList) {
+ if (!pkValuesMap.containsKey(columnName)) {
+ pkValuesMap.put(columnName, getGeneratedKeys(columnName));
+ }
+ }
+ return pkValuesMap;
+ }
+
+ /**
+ * Whether the insert columns contain any pk columns
+ *
+ * @return true: contain at least one pk column. false: do not contain any pk columns
+ */
+ public boolean containsAnyPk() {
+ SQLInsertRecognizer recognizer = (SQLInsertRecognizer)sqlRecognizer;
+ List insertColumns = recognizer.getInsertColumns();
+ if (CollectionUtils.isEmpty(insertColumns)) {
+ return false;
+ }
+ List pkColumnNameList = getTableMeta().getPrimaryKeyOnlyName();
+ if (CollectionUtils.isEmpty(pkColumnNameList)) {
+ return false;
+ }
+ List newColumns = ColumnUtils.delEscape(insertColumns, getDbType());
+ return pkColumnNameList.stream().anyMatch(pkColumn -> newColumns.contains(pkColumn)
+ || CollectionUtils.toUpperList(newColumns).contains(pkColumn.toUpperCase()));
+ }
+
+ @Override
+ public Map> getPkValuesByColumn() throws SQLException {
+ Map> pkValuesMap = parsePkValuesFromStatement();
+ Set keySet = pkValuesMap.keySet();
+ for (String pkKey : keySet) {
+ List