Migrating from an Activiti Framework Database to the DM/Kingbase/Vastbase Database
You can modify the JAR package on which the project depends to complete the migration, or modify the obtained Activiti framework source code and package it into a JAR package to complete the migration. In this migration guide, the JAR Editor plugin is used to directly modify the JAR package.
Prerequisites
- You are advised to perform the operations in IntelliJ IDEA and install the JAR Editor plugin.
- It is strongly recommended that you migrate the framework after you have migrated the database or when you have the complete table structure.
Adapting Activiti to DM
- Use IntelliJ IDEA to open the dependency package org.activiti:activiti-engine and use the JAR Editor plugin to modify the JAR package.
- Locate the activiti-engine module and modify only two classes and the SQL file.
- Open the org/activiti/engine/impl/cfg/ProcessEngineConfigurationImpl file.
Add the following code to the getDefaultDatabaseTypeMappings() method:
1databaseTypeMappings.setProperty("DMDBMS","dm");
Use the JAR Editor to save and compile the file, and then rebuild the JAR package. Ensure that the JDK version is the same as the JDK version (JDK 11) compatible with the Activiti framework.
In some cases, compilation errors may occur. The possible causes are as follows:- The dependency packages invoked by the Activiti framework are incompatible with those invoked by the migration project source code.
- The JDK version is incorrect.
- Modify the org/activiti/engine/impl/db/DbSqlSessionFactory class by adding the following code to the static block:
1 2 3 4 5 6 7 8 9
// 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");
Use the JAR Editor to save and compile the file, and then rebuild the JAR package. Ensure that the JDK version is the same as the JDK version (JDK 11) compatible with the Activiti framework.
- Copy the Oracle database SQL files in the create, drop, and upgrade folders in org/activiti/db, and replace oracle in the file names with dm.
Use the JAR Editor to rebuild the JAR package. Ensure that the JDK version is the same as the JDK version (JDK 11) compatible with the Activiti framework.
- Open the org/activiti/engine/impl/cfg/ProcessEngineConfigurationImpl file.
Adapting Activiti to Kingbase
- Use IntelliJ IDEA to open the dependency package org.activiti:activiti-engine and use the JAR Editor plugin to modify the JAR package.
- Locate the activiti-engine module and modify only two classes and the SQL file.
- Open the org/activiti/engine/impl/cfg/ProcessEngineConfigurationImpl file.Add the following code to the getDefaultDatabaseTypeMappings() method:
1databaseTypeMappings.setProperty("KingbaseES","kingbase8");
Use the JAR Editor to save and compile the file, and then rebuild the JAR package. Ensure that the JDK version is the same as the JDK version (JDK 11) compatible with the Activiti framework.
In some cases, compilation errors may occur. The possible causes are as follows:- The dependency packages invoked by the Activiti framework are incompatible with those invoked by the migration project source code.
- The JDK version is incorrect.
- Modify the org/activiti/engine/impl/db/DbSqlSessionFactory class by adding the following code to the static block:
1 2 3 4 5 6 7 8 9
// kingbase databaseSpecificLimitBeforeStatements.put("kingbase8", "select * from ( select a.*, ROWNUM rnum from ("); databaseSpecificLimitAfterStatements.put("kingbase8", " ) a where ROWNUM < #{lastRow}) where rnum >= #{firstRow}"); databaseSpecificLimitBetweenStatements.put("kingbase8", ""); databaseOuterJoinLimitBetweenStatements.put("kingbase8", ""); databaseSpecificOrderByStatements.put("kingbase8", defaultOrderBy); addDatabaseSpecificStatement("kingbase8", "selectExclusiveJobsToExecute", "selectExclusiveJobsToExecute_integerBoolean"); addDatabaseSpecificStatement("kingbase8", "selectUnlockedTimersByDuedate", "selectUnlockedTimersByDuedate_oracle"); addDatabaseSpecificStatement("kingbase8", "insertEventLogEntry", "insertEventLogEntry_oracle");
Use the JAR Editor to save and compile the file, and then rebuild the JAR package. Ensure that the JDK version is the same as the JDK version (JDK 11) compatible with the Activiti framework.
- Copy the Oracle database SQL files in the create, drop, and upgrade folders in org/activiti/db, and replace oracle in the file names with kingbase8.
Use the JAR Editor to rebuild the JAR package. Ensure that the JDK version is the same as the JDK version (JDK 11) compatible with the Activiti framework.
- Open the org/activiti/engine/impl/cfg/ProcessEngineConfigurationImpl file.
Adapting Activiti to Vastbase
Vastbase is fully compatible with MySQL. To adapt Activiti to Vastbase, you only need to introduce the dependencies of MySQL and modify the database configuration in the configuration file. For example:
- If Activiti is integrated in the Spring Boot project, modify the following configuration file to complete the adaptation. The following uses the YAML file as an example.
1 2 3 4 5 6 7 8
spring.datasource: # Configure the MySQL driver. driver-class-name: com.mysql.cj.jdbc.Driver # Set the database type in the URL to MySQL. url: jdbc:mysql://{Vastbase_IP_address}:{Vastbase_port}/{Database_name} # Example: jdbc:mysql://127.0.0.1:2881/CamundaProject username: {Vastbase_user_name} password: {Vastbase_login_password}
- The Activiti framework may also use another type of configuration file. The following is the configuration content in the activiti.cfg.xml file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Database configuration --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.cj.jdbc.Driver" /> <property name="url" value="jdbc:mysql://{Vastbase_IP_address}:{Vastbase_port}/{Database_name}/> <property name="username" value="{Database_user_name}" />; <property name="password" value="{Database_password}" />; <!-- ..Other configuration --> <property name=".." value=".." /> </bean> ... </beans>
After completing the configuration, start the project. If a correct database table is generated in the database, the adaptation is successful.