xxl-job DB无关实现,建议优化

5lhxktic  于 2021-11-29  发布在  Java
关注(0)|答案(7)|浏览(417)

Please answer some questions before submitting your issue. Thanks!

Which version of XXL-JOB do you using?

2.1.1

Expected behavior

DB无关实现(兼容Oracle/H2/DB2...)
建表语句、mapper均不兼容

Actual behavior

仅能在Mysql上使用

Steps to reproduce the behavior

Other information

pes8fvy9

pes8fvy92#

希望能支持主流数据库,mark

daolsyd0

daolsyd03#

赞同,现在调度中心的SQL依赖于MySQL,希望做到与RDBMS解耦合,不要强制用户使用MySQL。

yb3bgrhw

yb3bgrhw4#

希望实现迁移之后,还要出一个迁移文档,比如朝postgresql迁移的文档

p8ekf7hl

p8ekf7hl5#

希望官方能实现或合并pg的支持

hpcdzsge

hpcdzsge6#

可以使用mybatis的多数据库支持

mybatis-config.xml

<?xmlversion="1.0"encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
  <databaseIdProvider type="DB_VENDOR">
    <property name="MySQL" value="mysql"/>
    <property name="Oracle" value="oracle"/>
  </databaseIdProvider>
</configuration>

然后再 mapper.xml 中写

<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobGroup" useGeneratedKeys="true" keyProperty="id" >
	<if test="_databaseId == 'mysql'">
		INSERT INTO xxl_job_group ( `app_name`, `title`, `address_type`, `address_list`, `update_time`)
		values ( #{appname}, #{title}, #{addressType}, #{addressList}, #{updateTime} );
	</if>
	<if test="_databaseId == 'oracle'">
		INSERT INTO xxl_job_group (app_name, title, address_type, address_list, update_time)
		values ( #{appname}, #{title}, #{addressType}, #{addressList}, #{updateTime} )
	</if>
</insert>
txu3uszq

txu3uszq7#

@1725785880 你好,可以提供希望调整的SQL位置吗?

相关问题