flowable如何適配國產數據庫達夢


 

前言

flowable6.4.1流程引擎官方支持的數據庫有:MySQL、hsql、Oracle、DB2 、postgres、SQL Server、H2。對於其他類型的數據庫如何支持,尤其是國產數據庫的支持,下面以達夢數據庫為例進行介紹。對於其他國產數據庫如人大金倉、神州通用等也是同樣的修改方法,只是需要注意一下對應數據庫的方言即可。

一、引入達夢數據庫驅動包

在maven工程的Resources目錄下建lib目錄,放入達夢數據庫驅動包Dm7JdbcDriver17.jar,並配置maven為本地引用

dm.jdbc.driver.DmDriver
jdbc
system
${project.basedir}/src/main/resources/lib/Dm7JdbcDriver17.jar

二、配置達夢數據源

url: jdbc:dm://127.0.0.1:5236
username: oa
password: 12345678aA
driver-class-name: dm.jdbc.driver.DmDriver

三、修改flowable代碼,支持達夢數據庫

1. 修改ProcessEngineConfigurationImpl類的代碼

修改org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl類的getDefaultDatabaseTypeMappings方法。

public static final String DATABASE_TYPE_H2 = "h2";
    public static final String DATABASE_TYPE_HSQL = "hsql";
    public static final String DATABASE_TYPE_MYSQL = "mysql";
    public static final String DATABASE_TYPE_ORACLE = "oracle";
    public static final String DATABASE_TYPE_POSTGRES = "postgres";
    public static final String DATABASE_TYPE_MSSQL = "mssql";
    public static final String DATABASE_TYPE_DB2 = "db2";
 	public static final String DATABASE_TYPE_DM = "dm"; //達夢
 
    protected static Properties getDefaultDatabaseTypeMappings() {
   
        Properties databaseTypeMappings = new Properties();
        databaseTypeMappings.setProperty("H2", DATABASE_TYPE_H2);
        databaseTypeMappings.setProperty("HSQL Database Engine", DATABASE_TYPE_HSQL);
        databaseTypeMappings.setProperty("MySQL", DATABASE_TYPE_MYSQL);
        databaseTypeMappings.setProperty("Oracle", DATABASE_TYPE_ORACLE);
        databaseTypeMappings.setProperty("PostgreSQL", DATABASE_TYPE_POSTGRES);
        databaseTypeMappings.setProperty("Microsoft SQL Server", DATABASE_TYPE_MSSQL);
        databaseTypeMappings.setProperty(DATABASE_TYPE_DB2, DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/NT", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/NT64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2 UDP", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUX", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUX390", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUXX8664", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUXZ64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUXPPC64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/LINUXPPC64LE", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/400 SQL", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/6000", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2 UDB iSeries", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/AIX64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/HPUX", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/HP64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/SUN", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/SUN64", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/PTX", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2/2", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DB2 UDB AS400", DATABASE_TYPE_DB2);
        databaseTypeMappings.setProperty("DM DBMS", DATABASE_TYPE_DM); //達夢
        
        return databaseTypeMappings;
    }

2. 修改DbSqlSessionFactory類代碼

org.activiti.engine.impl.db.DbSqlSessionFactory類里增加對達夢數據庫的語法解析,在static方法里增加:

// dm
        databaseSpecificLimitBeforeStatements.put("dm", "select * from ( select a.*, ROWNUM rnum from (");
        databaseSpecificLimitAfterStatements.put("dm", " ) a where ROWNUM < #{lastRow}) where rnum >= #{firstRow}");
        databaseSpecificLimitBetweenStatements.put("dm", "");
        databaseOuterJoinLimitBetweenStatements.put("dm", "");
        databaseSpecificOrderByStatements.put("dm", defaultOrderBy);
        addDatabaseSpecificStatement("dm", "selectExclusiveJobsToExecute", "selectExclusiveJobsToExecute_integerBoolean");
        addDatabaseSpecificStatement("dm", "selectUnlockedTimersByDuedate", "selectUnlockedTimersByDuedate_oracle");
        addDatabaseSpecificStatement("dm", "insertEventLogEntry", "insertEventLogEntry_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertVariableInstance", "bulkInsertVariableInstance_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertTask", "bulkInsertTask_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertResource", "bulkInsertResource_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertProperty", "bulkInsertProperty_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertProcessDefinition", "bulkInsertProcessDefinition_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertModel", "bulkInsertModel_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertTimer", "bulkInsertTimer_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertMessage", "bulkInsertMessage_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertIdentityLink", "bulkInsertIdentityLink_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertHistoricVariableInstance", "bulkInsertHistoricVariableInstance_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertHistoricTaskInstance", "bulkInsertHistoricTaskInstance_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertHistoricProcessInstance", "bulkInsertHistoricProcessInstance_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertHistoricIdentityLink", "bulkInsertHistoricIdentityLink_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertHistoricDetailVariableInstanceUpdate", "bulkInsertHistoricDetailVariableInstanceUpdate_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertHistoricFormProperty", "bulkInsertHistoricFormProperty_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertHistoricActivityInstance", "bulkInsertHistoricActivityInstance_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertExecution", "bulkInsertExecution_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertMessageEventSubscription", "bulkInsertMessageEventSubscription_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertSignalEventSubscription", "bulkInsertSignalEventSubscription_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertCompensateEventSubscription", "bulkInsertCompensateEventSubscription_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertEventLogEntry", "bulkInsertEventLogEntry_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertDeployment", "bulkInsertDeployment_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertComment", "bulkInsertComment_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertByteArray", "bulkInsertByteArray_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertEventLogEntry", "bulkInsertEventLogEntry_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertDeployment", "bulkInsertDeployment_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertComment", "bulkInsertComment_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertAttachment", "bulkInsertAttachment_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertJob", "bulkInsertJob_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertTimerJob", "bulkInsertTimerJob_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertSuspendedJob", "bulkInsertSuspendedJob_oracle");
        addDatabaseSpecificStatement("dm", "bulkInsertDeadLetterJob", "bulkInsertDeadLetterJob_oracle");

四、推薦選型

筆者從事工作流研發多年,用過osworkflow、jbpm、activiti、flowable、camunda等多個開源流程引擎,后來遇到了camunda,經過功能和性能驗證測試,最終選擇了camunda。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM