稷然如此

  • 首页
  • 文章分类
    • AI
    • Android
    • Java
    • Shell
    • Vue
    • C#
    • Python
    • 数据库
    • 组件
    • 其他
    • Game
  • 常用命令
    • Docker
    • Git
    • Linux
  • 操作系统
    • CentOS
    • Ubuntu
    • Windows
    • Kylin
  • 工具
    • IntelliJ IDEA
    • Visual Studio Code
稷然如此
不积跬步,无以至千里
  1. 首页
  2. 文章分类
  3. Java
  4. 正文

Activiti 流程引擎适配达梦数据库

2025年6月6日 35点热度 0人点赞
1.环境
Spring MVC
Activiti 5.22.0
2.适配达梦
方式一:升级 activiti,据说activiti 8 支持达梦,考虑到兼容问题,不采用。
方式二:
直接改包,然后再引入改好后的 jar 包,这个方法麻烦,不推荐。
方式三:
1.需要改造到的类有以下几个:
# 以下需要改造的类从原始类中复制粘贴再进行改造
org.activiti.engine.impl.AbstractQuery
org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl
org.activiti.engine.impl.db.DbSqlSession
org.activiti.engine.impl.db.DbSqlSessionFactory
2.在引用了 activiti 的工程下新建以上对应的包(覆盖原官方包,以及改造的以下类作覆盖用)
3.改造内容如下,看注释 // TODO 部分为改造内容:
1.AbstractQuery
protected void addOrder(String column, String sortOrder, NullHandlingOnOrder nullHandlingOnOrder) {
        if (this.orderBy == null) {
            this.orderBy = "";
        } else {
            this.orderBy = this.orderBy + ", ";
        }

        String defaultOrderByClause = column + " " + sortOrder;
        if (nullHandlingOnOrder != null) {
            if (nullHandlingOnOrder.equals(AbstractQuery.NullHandlingOnOrder.NULLS_FIRST)) {
                // TODO 条件新增 !"dm".equals(this.databaseType)
                if (!"h2".equals(this.databaseType) && !"hsql".equals(this.databaseType) && !"postgres".equals(this.databaseType) && !"oracle".equals(this.databaseType) && !"dm".equals(this.databaseType)) {
                    if ("mysql".equals(this.databaseType)) {
                        this.orderBy = this.orderBy + "isnull(" + column + ") desc," + defaultOrderByClause;
                    } else if (!"db2".equals(this.databaseType) && !"mssql".equals(this.databaseType)) {
                        this.orderBy = this.orderBy + defaultOrderByClause;
                    } else {
                        this.orderBy = this.orderBy + "case when " + column + " is null then 0 else 1 end," + defaultOrderByClause;
                    }
                } else {
                    this.orderBy = this.orderBy + defaultOrderByClause + " NULLS FIRST";
                }
            } else if (nullHandlingOnOrder.equals(AbstractQuery.NullHandlingOnOrder.NULLS_LAST)) {
                // TODO 条件新增 !"dm".equals(this.databaseType)
                if (!"h2".equals(this.databaseType) && !"hsql".equals(this.databaseType) && !"postgres".equals(this.databaseType) && !"oracle".equals(this.databaseType) && !"dm".equals(this.databaseType)) {
                    if ("mysql".equals(this.databaseType)) {
                        this.orderBy = this.orderBy + "isnull(" + column + ") asc," + defaultOrderByClause;
                    } else if (!"db2".equals(this.databaseType) && !"mssql".equals(this.databaseType)) {
                        this.orderBy = this.orderBy + defaultOrderByClause;
                    } else {
                        this.orderBy = this.orderBy + "case when " + column + " is null then 1 else 0 end," + defaultOrderByClause;
                    }
                } else {
                    this.orderBy = this.orderBy + column + " " + sortOrder + " NULLS LAST";
                }
            }
        } else {
            this.orderBy = this.orderBy + defaultOrderByClause;
        }

    }
2.ProcessEngineConfigurationImpl
protected static Properties getDefaultDatabaseTypeMappings() {
        Properties databaseTypeMappings = new Properties();
        // TODO 新增 databaseTypeMappings.setProperty("DM DBMS", "dm");
        databaseTypeMappings.setProperty("DM DBMS", "dm");
        databaseTypeMappings.setProperty("H2", "h2");
        databaseTypeMappings.setProperty("HSQL Database Engine", "hsql");
        databaseTypeMappings.setProperty("MySQL", "mysql");
        databaseTypeMappings.setProperty("Oracle", "oracle");
        databaseTypeMappings.setProperty("PostgreSQL", "postgres");
        databaseTypeMappings.setProperty("Microsoft SQL Server", "mssql");
        databaseTypeMappings.setProperty("db2", "db2");
        databaseTypeMappings.setProperty("DB2", "db2");
        databaseTypeMappings.setProperty("DB2/NT", "db2");
        databaseTypeMappings.setProperty("DB2/NT64", "db2");
        databaseTypeMappings.setProperty("DB2 UDP", "db2");
        databaseTypeMappings.setProperty("DB2/LINUX", "db2");
        databaseTypeMappings.setProperty("DB2/LINUX390", "db2");
        databaseTypeMappings.setProperty("DB2/LINUXX8664", "db2");
        databaseTypeMappings.setProperty("DB2/LINUXZ64", "db2");
        databaseTypeMappings.setProperty("DB2/LINUXPPC64", "db2");
        databaseTypeMappings.setProperty("DB2/LINUXPPC64LE", "db2");
        databaseTypeMappings.setProperty("DB2/400 SQL", "db2");
        databaseTypeMappings.setProperty("DB2/6000", "db2");
        databaseTypeMappings.setProperty("DB2 UDB iSeries", "db2");
        databaseTypeMappings.setProperty("DB2/AIX64", "db2");
        databaseTypeMappings.setProperty("DB2/HPUX", "db2");
        databaseTypeMappings.setProperty("DB2/HP64", "db2");
        databaseTypeMappings.setProperty("DB2/SUN", "db2");
        databaseTypeMappings.setProperty("DB2/SUN64", "db2");
        databaseTypeMappings.setProperty("DB2/PTX", "db2");
        databaseTypeMappings.setProperty("DB2/2", "db2");
        databaseTypeMappings.setProperty("DB2 UDB AS400", "db2");
        return databaseTypeMappings;
    }
3.DbSqlSession
public String getResourceForDbOperation(String directory, String operation, String component) {
        String databaseType = this.dbSqlSessionFactory.getDatabaseType();
       // TODO 新增以下判断,使用 oracle sql文件
       if("dm".equals(databaseType)) {
            databaseType = "oracle";
        }
        return "org/activiti/db/" + directory + "/activiti." + databaseType + "." + operation + "." + component + ".sql";
    }
4.DbSqlSessionFactory
protected void initBulkInsertEnabledMap(String databaseType) {
        bulkInsertableMap = new HashMap();

        for(Class<? extends PersistentObject> clazz : EntityDependencyOrder.INSERT_ORDER) {
            bulkInsertableMap.put(clazz, Boolean.TRUE);
        }
        // TODO 新增  || "dm".equals(databaseType) 判断条件
        if ("oracle".equals(databaseType) || "dm".equals(databaseType)) {
            bulkInsertableMap.put(EventLogEntryEntity.class, Boolean.FALSE);
        }

    }
标签: 暂无
最后更新:2025年6月6日

Akim

犇 骉 Java、C#、Python、Go、Android、MiniProgram、Bootstrap、Vue2

点赞
< 上一篇

Copyright © 2025 aianran.com All Rights Reserved.

免责申明 | 隐私政策 | 服务条款 | 关于我们

黔ICP备2023008200号-1

贵公网安备 52010202003594号