首页 > 其他分享 >111

111

时间:2024-01-17 15:56:37浏览次数:32  
标签:VARCHAR flowable jar kingbase addDatabaseSpecificStatement 111 oracle


 

转自:https://blog.csdn.net/qq_42505088/article/details/108196487

flowable兼容国产金仓数据库

 

1、新增jar包的sql脚本

(flowable框架不支持金仓数据库,需要手动插入sql脚本)
需要修改的几个jar包脚本
需要修改的几个jar包

在这里插入图片描述

  1. 因为金仓数据库语法类似oracle,赋值在org/flowable/db/create中,复制该jar包中的orcale脚本(脚本名称格式:flowable.oracle.create.XXX.sql)为新文件,并修改成文件名为:flowable.数据库类型.create.XXX.sql(如,金仓脚本名称格式:flowable.kingbase.create.XXX.sql),如下图:
    在这里插入图片描述
    在这里插入图片描述
    注:修改脚本中的*为30,金仓不支持语法
    2.把flowable.kingbase.create.XXX.sql按照本来的包名格式的样列复制到flowable的工作目录中去
    如图:
    在这里插入图片描述

2、修改源码

1、修改源码org.flowable.common.engine.impl.AbstractEngineConfiguration
(1)在maven仓库下打开org\flowable\flowable-engine-common\6.4.2,找到flowable-engine-common-6.4.2-sources.jar文件,用解压工具打开。
(2)在jar包中打开org\flowable\common\engine\impl\目录找到AbstractEngineConfiguration.java,在编辑器下根据该java文件的package创建相同的包名,并将其复制到我们自己实现的工程(flowengine)相同包名下,进行修改,插入以下两行

public static final String DATABASE_TYPE_KINGBASE = "kingbase";
public static Properties getDefaultDatabaseTypeMappings() {
        databaseTypeMappings.setProperty("KingbaseES", DATABASE_TYPE_KINGBASE);
 
  • 1
  • 2
  • 3

2、修改源码DatabaseConfiguration.java
(1)在maven仓库下打开org\flowable\flowable-ui-modeler-conf\6.4.2,找到flowable-ui-modeler-conf-6.4.2-sources.jar文件,用压缩包打开。
(2)在jar包中打开org\flowable\ui\modeler\conf目录找到DatabaseConfiguration.java,在编辑器下根据该java文件的package创建相同的包名,并将其复制到我们自己实现的工程(flowengine)相同包名下进行修改。

//添加金仓数据库
public static final String DATABASE_TYPE_KINGBASE = "kingbase";
public static Properties getDefaultDatabaseTypeMappings() {
    databaseTypeMappings.setProperty("KingbaseES", DATABASE_TYPE_KINGBASE);
}
//修改liquibase的bean方法
@Bean
public Liquibase liquibase(DataSource dataSource) {
    LOGGER.info("Configuring Liquibase");

    Liquibase liquibase = null;
    try {
        DatabaseConnection connection = new JdbcConnection(dataSource.getConnection());
        Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(connection);
        database.setDatabaseChangeLogTableName(LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogTableName());
        database.setDatabaseChangeLogLockTableName(LIQUIBASE_CHANGELOG_PREFIX + database.getDatabaseChangeLogLockTableName());
        String defaultSchemaName=env.getProperty("spring.jpa.properties.hibernate.default_schema");
        if(defaultSchemaName!=null&&!defaultSchemaName.equals("")){
        	database.setDefaultSchemaName(defaultSchemaName);
            database.setLiquibaseSchemaName(defaultSchemaName);
        }
        liquibase = new Liquibase("META-INF/liquibase/flowable-modeler-app-db-changelog.xml", new ClassLoaderResourceAccessor(), database);
        liquibase.update("flowable");
        return liquibase;

    } catch (Exception e) {
        throw new InternalServerErrorException("Error creating liquibase database", e);
    } finally {
        closeDatabase(liquibase);
    }
}
 

3、复制修改ProcessEngineConfigurationImpl.java源码
(1)在maven仓库下打开org\flowable\flowable5-engine\6.4.2,找到flowable5-engine-6.4.2-sources.jar文件,用压缩包打开。
(2)在jar包中打开org\activiti\engine\impl\cfg\目录找到ProcessEngineConfigurationImpl.java,在编辑器下根据该java文件的package创建相同的包名,并将其复制到我们自己实现的工程(flowengine)相同包名下进行添加修改。

//添加金仓数据库
public static final String DATABASE_TYPE_KINGBASE = "kingbase";
public static Properties getDefaultDatabaseTypeMappings() {
    databaseTypeMappings.setProperty("KingbaseES", DATABASE_TYPE_KINGBASE);
}
 

4、复制修改DbSqlSessionFactory.java源码
(1)在maven仓库下打开org\flowable\flowable5-engine\6.4.2,找到flowable5-engine-6.4.2-sources.jar文件,用压缩包打开。
(2)在jar包中打开org\activiti\engine\impl\db\目录找到DbSqlSessionFactory.java,在编辑器下根据改java文件的包package创建相同的包名,并将其复制到我们自己实现的工程(flowengine)相同包名下进行修改。
在静态代码中加上

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

3、修改liquibase相关

(1)在maven仓库下打开flowable\flowable-ui-modeler-logic\6.4.2,找到flowable-ui-modeler-logic-6.4.2.jar文件,用压缩包打开。
(2)进入jar包后打开META-INF\liquibase目录,把flowable-modeler-app-db-changelog.xml复制出来并在jar包中删除(必须在jar包中删除,不然会因为检索到两个文件报错)。
(3)在工作流引擎的微服务工程中,在src/main/resources中创建文件夹META-INF/liquibase,然后把flowable-modeler-app-db-changelog.xml复制到自己的工作目录下(已经存在“修改工作流的源码”目录中,使用者只需把目录中的文件复制到自己的工程中即可)
(4)使用金仓数据库时修改flowable-modeler-app-db-changelog.xml文件,把内容改为如下:
(主要是因为金仓不支持liquibase自动生成的创建索引语句)

<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
	xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
    <changeSet id="3" author="flowable">
        <addColumn tableName="ACT_DE_MODEL">
            <column  name="tenant_id" type="varchar(255)" />
        </addColumn>
        <addColumn tableName="ACT_DE_MODEL_HISTORY">
            <column  name="tenant_id" type="varchar(255)" />
        </addColumn>
    </changeSet>
</databaseChangeLog>
 

(5)在org\flowable\db\create\flowable.kingbase.create.engine.sql脚本文件,加入以下SQL语句:

CREATE TABLE ACT_DE_MODEL (
id VARCHAR(255) NOT NULL,
name VARCHAR(400) NOT NULL,
model_key VARCHAR(400) NOT NULL,
description VARCHAR(4000),
model_comment VARCHAR(4000),
created timestamp,
created_by VARCHAR(255),
last_updated timestamp,
last_updated_by VARCHAR(255),
"version" INT, 
model_editor_json CLOB,
thumbnail BLOB,
model_type INT,
CONSTRAINT PK_ACT_DE_MODEL PRIMARY KEY (id));

CREATE TABLE ACT_DE_MODEL_HISTORY (
id VARCHAR(255) NOT NULL,
name VARCHAR(400) NOT NULL,
model_key VARCHAR(400) NOT NULL,
description VARCHAR(4000),
model_comment VARCHAR(4000),
created timestamp,
created_by VARCHAR(255),
last_updated timestamp,
last_updated_by VARCHAR(255),
removal_date timestamp,
"version" INT,
model_editor_json CLOB,
model_id VARCHAR(255) NOT NULL,
model_type INT, 
CONSTRAINT PK_ACT_DE_MODEL_HISTORY PRIMARY KEY (id));

CREATE INDEX idx_proc_mod_created ON ACT_DE_MODEL(created_by);
CREATE INDEX idx_proc_mod_history_proc ON ACT_DE_MODEL_HISTORY(model_id);

CREATE TABLE ACT_DE_DATABASECHANGELOGLOCK (
ID INT NOT NULL, 
LOCKED BOOL NOT NULL, 
LOCKGRANTED TIMESTAMP, 
LOCKEDBY VARCHAR(255), 
CONSTRAINT PK_ACT_DE_DATABASECHANGELOGLOCK PRIMARY KEY (ID));

CREATE TABLE ACT_DE_DATABASECHANGELOG (
ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL,
FILENAME VARCHAR(255) NOT NULL,
DATEEXECUTED TIMESTAMP NOT NULL, 
ORDEREXECUTED INT NOT NULL,
EXECTYPE VARCHAR(10) NOT NULL,
MD5SUM VARCHAR(35),
DESCRIPTION VARCHAR(255), 
COMMENTS VARCHAR(255), 
TAG VARCHAR(255),
LIQUIBASE VARCHAR(20), 
CONTEXTS VARCHAR(255), 
LABELS VARCHAR(255), 
DEPLOYMENT_ID VARCHAR(10));

4、配置文件

在pom.xml文件中加入金仓的依赖:

<dependency>
    <groupId>com.kingbase</groupId>
    <artifactId>kingbase8</artifactId>
    <version>8.2.0</version>
</dependency>
<dependency>
    <groupId>com.kingbase.dialect</groupId>
    <artifactId>kingbase8</artifactId>
    <version>8.2.0</version>
</dependency>
 

在application.properties中加入以下配置:

spring.jpa.properties.hibernate.autoReconnect=true
spring.datasource.driver-class-name=com.kingbase8.Driver
//金仓数据库名固定为大写
spring.datasource.url=jdbc:kingbase8://{ip}:{port}/{数据库名}?characterEncoding=utf-8&createDatabaseIfNotExist=true&SSL=false&nullCatalogMeansCurrent=true
spring.datasource.username={用户名}
spring.datasource.password={密码}
//基本语法与oracle类似
spring.jpa.database=oracle
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Kingbase8Dialect
//金仓模式名固定为public
spring.jpa.properties.hibernate.default_schema=PUBLIC 
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.hbm2ddl.auto=update
spring.jpa.properties.hibernate.show_sql=true
       

标签:VARCHAR,flowable,jar,kingbase,addDatabaseSpecificStatement,111,oracle
From: https://www.cnblogs.com/sensenh/p/17970212

相关文章

  • 独立开发者碎碎念 1115
    关于心态❤在巨大焦虑的心态下,人都来不及生病。我记忆中,高考前神经高度紧张,高考后一场大病如期而至。人啊,真复杂。心态啊,真正能做到面对任何事客观平常心的,有几个呢因此尽可能保持客观平常心面对,想到最糟糕的结局和处理方式吧关于目标......
  • CentOS 8.5 (2111) 发布 -- 最后一代 CentOS
    作者主页:sysin.org没想到Redhat还继续发布了CentOS8.5,并提醒您不应该在生产中使用CentOSLinux8。生命周期仍然是年底结束(End-of-life31December2021)。对于CentOS8.5看看就好,请速迁移到AlmaLinux或者RockyLinux。我们很高兴地宣布最新的CentOSLinux8版本。立即......
  • macOS Big Sur 11.7.3 (20G1116) 正式版 ISO、PKG、DMG、IPSW 下载
    本站提供的macOSBigSur软件包,既可以拖拽到Applications(应用程序)下直接安装,也可以制作启动U盘安装,或者在虚拟机中启动安装。作者主页:www.sysin.orgmacOSBigSur11.7.x同样为安全更新,不再赘述。macOSBigSur11.6.x皆为安全更新,不再赘述。macOSBigSur11.6.5(20G5......
  • 111
    #include<bits/stdc++.h>usingnamespacestd;intmain(){list<int>a;intb[]={1,2,3,4};list<int>c(b,b+sizeof(b)/sizeof(int));a.insert(a.begin(),c.begin(),c.end());a.insert(a.begin(),3,1);//在容器首位添加元素......
  • 111
    #include<iostream>#include<list>#include<algorithm>usingnamespacestd;intmain(){ list<int>a; intb[]={1,2,3,4}; list<int>c(b,b+sizeof(b)/sizeof(int)); a.insert(a.begin(),c.begin(),c.end()); a.insert(a.begin(),......
  • 111
    #include<iostream>usingnamespacestd;voidMAIN();intmain(){intn;while(1){MAIN();cin>>n;inttime;switch(n){case1:{cout<<"请输入等待关机时间:";......
  • 11111111
    #include<iostream>#include<vector>#include<windows.h>usingnamespacestd;inta=999;intb=0;boolc=false;structstudent{ stringname; intage; intcard; intgrade;}s;voidka(){ cout<<"学生管理系统:"<<endl; c......
  • 代码随想录算法训练营第十六天 |104.二叉树的最大深度,559.n叉树的最大深度,111.二叉树
    一、104.二叉树的最大深度题目链接:LeetCode104.二叉树的最大深度学习:思路:分别求左子树和右子树的高度,返回给根结点,加1之后是根结点的深度,这是后序遍历的思路二、559.n叉树的最大深度题目链接:LeetCode559.N叉树的最大深度学习前:思路:后序遍历。分别所有孩子结点的深......
  • [LeetCode Hot 100] LeetCode111. 二叉树的最小深度
    题目描述思路二叉树的最小深度就是第一个叶子节点所在的层数方法一:前序遍历(递归、dfs)/***Definitionforabinarytreenode.*publicclassTreeNode{*intval;*TreeNodeleft;*TreeNoderight;*TreeNode(){}*TreeNode(intva......
  • ORA-01113: file 69 needs media recovery ORA-01110: data file 69: 'E:\FWPTDB\D
    继续上一篇写1、当解决了ORA-01033:ORACLEinitializationorshutdowninprogress 这个问题后重新连接此数据库的时候又出现以下问题ORA-01113:file69needsmediarecovery ORA-01110:datafile69:'E:\FWPTDB\DBFFILES\HNRZ\HNRZFW.DBF2、解决方案  ......