zhangchg452862 3 år sedan
förälder
incheckning
b04475544f

+ 4 - 0
mybatis-plus-annotation/src/main/java/com/baomidou/mybatisplus/annotation/DbType.java

@@ -135,6 +135,10 @@ public enum DbType {
      * CSIIDB
      */
     CSIIDB("csiidb", "CSIIDB数据库"),
+    /**
+     * CSIIDB
+     */
+    SAP_HANA("hana", "SAP_HANA数据库"),
     /**
      * UNKONWN DB
      */

+ 38 - 0
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/incrementer/SapHanaKeyGenerator.java

@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011-2021, baomidou (jobob@qq.com).
+ *
+ * Licensed 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 com.baomidou.mybatisplus.extension.incrementer;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
+
+/**
+ * SAP_HANA Key Sequence 生成器
+ *
+ * @author zhangchg
+ * @since 2021-12-03
+ */
+public class SapHanaKeyGenerator implements IKeyGenerator {
+
+    @Override
+    public String executeSql(String incrementerName) {
+        return "SELECT " + incrementerName + ".NEXTVAL FROM DUMMY";
+    }
+
+    @Override
+    public DbType dbType() {
+        return DbType.SAP_HANA;
+    }
+}

+ 2 - 1
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/plugins/pagination/DialectFactory.java

@@ -62,7 +62,8 @@ public class DialectFactory {
                 || dbType == DbType.SQLITE
                 || dbType == DbType.HSQL
                 || dbType == DbType.KINGBASE_ES
-                || dbType == DbType.PHOENIX) {
+                || dbType == DbType.PHOENIX
+                || dbType == DbType.SAP_HANA) {
                 dialect = new PostgreDialect();
             } else if (dbType == DbType.HIGH_GO) {
                 dialect = new HighGoDialect();

+ 3 - 1
mybatis-plus-extension/src/main/java/com/baomidou/mybatisplus/extension/toolkit/JdbcUtils.java

@@ -111,7 +111,9 @@ public class JdbcUtils {
             return DbType.GOLDILOCKS;
         } else if (url.contains(":csiidb:")) {
             return DbType.CSIIDB;
-        } else {
+        } else if (url.contains(":sap:")) {
+            return DbType.SAP_HANA;
+        }else {
             logger.warn("The jdbcUrl is " + jdbcUrl + ", Mybatis Plus Cannot Read Database type or The Database's Not Supported!");
             return DbType.OTHER;
         }