[Kingbase8 database] flowable is compatible with the Kingbase8 process of Renmin University of Finance and Economics

Database connection configuration

jdbc:kingbase8://xx:54321/b?useUnicode=true&characterEncoding=UTF-8
spring.datasource.dfeformdb.driver-class-name=com.kingbase8.Driver

Exclude non-essential jars

If only bpmn is used, dmn and cmmn can be excluded.

<exclusion>
                   <groupId>org.flowable</groupId>
                   <artifactId>flowable-spring-boot-starter-dmn</artifactId>
               </exclusion>
               <exclusion>
                   <groupId>org.flowable</groupId>
                   <artifactId>flowable-spring-boot-starter-cmmn</artifactId>
               </exclusion>
               <exclusion>
                   <groupId>org.flowable</groupId>
                   <artifactId>flowable-dmn-engine</artifactId>
               </exclusion>
               <exclusion>
                   <groupId>org.flowable</groupId>
                   <artifactId>flowable-dmn-spring</artifactId>
               </exclusion>
               <exclusion>
                   <groupId>org.flowable</groupId>
                   <artifactId>flowable-cmmn-engine</artifactId>
               </exclusion>
               <exclusion>
                   <groupId>org.flowable</groupId>
                   <artifactId>flowable-cmmn-spring</artifactId>
               </exclusion>

Modify liquibase

Configuration file
Add the dependencies of Jincang to the pom.xml file:

  <dependency>
                <groupId>com.kingbase8</groupId>
                <artifactId>kingbase8-jdbc</artifactId>
                <version>8.2.0.2</version>
            </dependency>
            <dependency>
                <groupId>com.kingbase.dialect</groupId>
                <artifactId>kingbase8</artifactId>
                <version>8.2.0.2</version>
            </dependency>

Refer to the official documentation:
https://help.kingbase.com.cn/v8/development/client-interfaces-frame/liquibase/liquibase-2.html

Modify flowable source code to add database type

Find AbstractEngineConfiguration.java, create the same package name according to the package of the java file in the editor, and copy it to the same package name of our own implemented project (flowengine), modify it, and insert the following two lines

package org.flowable.common.engine.impl;
public static Properties getDefaultDatabaseTypeMappings() {
              databaseTypeMappings.setProperty("KingbaseES", "postgres");
        return databaseTypeMappings;
    }

Modify the source code DatabaseConfiguration.java

Modify supported database types

 CREATE TABLE PUBLIC.FLW_EV_DATABASECHANGELOGLOCK (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP, LOCKEDBY VARCHAR(255), CONSTRAINT PK_FLW_EV_DATABASECHANGELOGLOCK PRIMARY KEY (ID))

Configure supported databases in \resources\META-INF\services\liquibase.database.Database

liquibase.database.core.PostgresDatabase
liquibase.database.core.SQLiteDatabase
liquibase.database.core.SybaseASADatabase
liquibase.database.core.SybaseDatabase
liquibase.database.core.KingbaseDatabase
liquibase.database.core.UnsupportedDatabase

Press liquibase.database.core.PostgresDatabase to increase the supported database types, public class KingbaseDatabase extends PostgresDatabase

Modify database field type conversion

 CREATE TABLE PUBLIC.FLW_EV_DATABASECHANGELOGLOCK (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP, LOCKEDBY VARCHAR(255), CONSTRAINT PK_FLW_EV_DATABASECHANGELOGLOCK PRIMARY KEY (ID))

liquibase.exception.DatabaseException: Error: The current transaction was terminated, and queries before the end of the transaction block were ignored

When executing sql alone, it was found that the datetime type
in org/flowable/eventregistry/db/liquibase/flowable-eventregistry-db-changelog.xml is not supported

  CREATE TABLE PUBLIC.FLW_EV_DATABASECHANGELOGLOCK (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED datetime, LOCKEDBY VARCHAR(255), CONSTRAINT PK_FLW_EV_DATABASECHANGELOGLOCK PRIMARY KEY (ID))

Change to

 CREATE TABLE PUBLIC.FLW_EV_DATABASECHANGELOGLOCK (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP, LOCKEDBY VARCHAR(255), CONSTRAINT PK_FLW_EV_DATABASECHANGELOGLOCK PRIMARY KEY (ID))

A better way is to add a new database type.

com.kingbase8.util.KSQLException: Error: Relationship "pg_settings" does not exist

Since the relationship "pg_settings" does not exist in kingbase8, there is only sys_settings, and also because of the call

@Override
   public void setConnection(DatabaseConnection conn) {
       super.setConnection(conn);

You can override liquibase.datatype.core.DateTimeType
to

if (database instanceof PostgresDatabase) {

Change to

if (database instanceof PostgresDatabase || database instanceof KingbaseDatabase) {

liquibase.exception.DatabaseException: Error: Syntax error at or near "."

Position: 27 [Failed SQL: (0) CREATE UNIQUE INDEX PUBLIC.ACT_IDX_EVENT_DEF_UNIQ ON PUBLIC.FLW_EVENT_DEFINITION(KEY_, VERSION_, TENANT_ID_)]

Because Kingbase does not support the index creation statement automatically generated by liquibase, do not bring PUBLIC., and override the method in KingbaseDatabase.

   @Override
   public boolean getOutputDefaultSchema() {
       return false;
   }

Reference: https://blog.csdn.net/LuoGuoHua_Xin/article/details/129898193

Guess you like

Origin blog.csdn.net/luansj/article/details/131519280