Skip to content

add support for kingbase #4810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,7 @@
import org.springframework.batch.item.database.JdbcPagingItemReader;
import org.springframework.batch.item.database.Order;
import org.springframework.batch.item.database.PagingQueryProvider;
import org.springframework.batch.item.database.support.AbstractSqlPagingQueryProvider;
import org.springframework.batch.item.database.support.Db2PagingQueryProvider;
import org.springframework.batch.item.database.support.DerbyPagingQueryProvider;
import org.springframework.batch.item.database.support.H2PagingQueryProvider;
import org.springframework.batch.item.database.support.HanaPagingQueryProvider;
import org.springframework.batch.item.database.support.HsqlPagingQueryProvider;
import org.springframework.batch.item.database.support.MariaDBPagingQueryProvider;
import org.springframework.batch.item.database.support.MySqlPagingQueryProvider;
import org.springframework.batch.item.database.support.OraclePagingQueryProvider;
import org.springframework.batch.item.database.support.PostgresPagingQueryProvider;
import org.springframework.batch.item.database.support.SqlServerPagingQueryProvider;
import org.springframework.batch.item.database.support.SqlitePagingQueryProvider;
import org.springframework.batch.item.database.support.SybasePagingQueryProvider;
import org.springframework.batch.item.database.support.*;
import org.springframework.batch.support.DatabaseType;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.DataClassRowMapper;
Expand Down Expand Up @@ -361,6 +349,7 @@ protected PagingQueryProvider determineQueryProvider(DataSource dataSource) {
case MARIADB -> new MariaDBPagingQueryProvider();
case ORACLE -> new OraclePagingQueryProvider();
case POSTGRES -> new PostgresPagingQueryProvider();
case KINGBASE -> new KingbasePagingQueryProvider();
case SYBASE -> new SybasePagingQueryProvider();
case SQLITE -> new SqlitePagingQueryProvider();
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,7 @@
import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer;
import org.springframework.jdbc.support.incrementer.MariaDBSequenceMaxValueIncrementer;

import static org.springframework.batch.support.DatabaseType.DB2;
import static org.springframework.batch.support.DatabaseType.DB2AS400;
import static org.springframework.batch.support.DatabaseType.DB2ZOS;
import static org.springframework.batch.support.DatabaseType.DERBY;
import static org.springframework.batch.support.DatabaseType.H2;
import static org.springframework.batch.support.DatabaseType.HANA;
import static org.springframework.batch.support.DatabaseType.HSQL;
import static org.springframework.batch.support.DatabaseType.MARIADB;
import static org.springframework.batch.support.DatabaseType.MYSQL;
import static org.springframework.batch.support.DatabaseType.ORACLE;
import static org.springframework.batch.support.DatabaseType.POSTGRES;
import static org.springframework.batch.support.DatabaseType.SQLITE;
import static org.springframework.batch.support.DatabaseType.SQLSERVER;
import static org.springframework.batch.support.DatabaseType.SYBASE;
import static org.springframework.batch.support.DatabaseType.*;

/**
* Default implementation of the {@link DataFieldMaxValueIncrementerFactory} interface.
Expand Down Expand Up @@ -120,6 +107,9 @@ else if (databaseType == ORACLE) {
else if (databaseType == POSTGRES) {
return new PostgresSequenceMaxValueIncrementer(dataSource, incrementerName);
}
else if (databaseType == KINGBASE) {
return new PostgresSequenceMaxValueIncrementer(dataSource, incrementerName);
}
else if (databaseType == SQLITE) {
return new SqliteMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.springframework.batch.item.database.support;

import org.springframework.util.StringUtils;


public class KingbasePagingQueryProvider extends AbstractSqlPagingQueryProvider {

@Override
public String generateFirstPageQuery(int pageSize) {
return SqlPagingQueryUtils.generateLimitSqlQuery(this, false, buildLimitClause(pageSize));
}

@Override
public String generateRemainingPagesQuery(int pageSize) {
if (StringUtils.hasText(getGroupClause())) {
return SqlPagingQueryUtils.generateLimitGroupedSqlQuery(this, buildLimitClause(pageSize));
}
else {
return SqlPagingQueryUtils.generateLimitSqlQuery(this, true, buildLimitClause(pageSize));
}
}

private String buildLimitClause(int pageSize) {
return new StringBuilder().append("LIMIT ").append(pageSize).toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@
*/
package org.springframework.batch.item.database.support;

import static org.springframework.batch.support.DatabaseType.DB2;
import static org.springframework.batch.support.DatabaseType.DB2VSE;
import static org.springframework.batch.support.DatabaseType.DB2ZOS;
import static org.springframework.batch.support.DatabaseType.DB2AS400;
import static org.springframework.batch.support.DatabaseType.DERBY;
import static org.springframework.batch.support.DatabaseType.H2;
import static org.springframework.batch.support.DatabaseType.HANA;
import static org.springframework.batch.support.DatabaseType.HSQL;
import static org.springframework.batch.support.DatabaseType.MARIADB;
import static org.springframework.batch.support.DatabaseType.MYSQL;
import static org.springframework.batch.support.DatabaseType.ORACLE;
import static org.springframework.batch.support.DatabaseType.POSTGRES;
import static org.springframework.batch.support.DatabaseType.SQLITE;
import static org.springframework.batch.support.DatabaseType.SQLSERVER;
import static org.springframework.batch.support.DatabaseType.SYBASE;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -45,6 +29,8 @@
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import static org.springframework.batch.support.DatabaseType.*;

/**
* Factory bean for {@link PagingQueryProvider} interface. The database type will be
* determined from the data source if not provided explicitly. Valid types are given by
Expand Down Expand Up @@ -85,6 +71,7 @@ public class SqlPagingQueryProviderFactoryBean implements FactoryBean<PagingQuer
providers.put(MARIADB, new MariaDBPagingQueryProvider());
providers.put(ORACLE, new OraclePagingQueryProvider());
providers.put(POSTGRES, new PostgresPagingQueryProvider());
providers.put(KINGBASE, new KingbasePagingQueryProvider());
providers.put(SQLITE, new SqlitePagingQueryProvider());
providers.put(SQLSERVER, new SqlServerPagingQueryProvider());
providers.put(SYBASE, new SybasePagingQueryProvider());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public enum DatabaseType {

DERBY("Apache Derby"), DB2("DB2"), DB2VSE("DB2VSE"), DB2ZOS("DB2ZOS"), DB2AS400("DB2AS400"),
HSQL("HSQL Database Engine"), SQLSERVER("Microsoft SQL Server"), MYSQL("MySQL"), ORACLE("Oracle"),
POSTGRES("PostgreSQL"), SYBASE("Sybase"), H2("H2"), SQLITE("SQLite"), HANA("HDB"), MARIADB("MariaDB");
POSTGRES("PostgreSQL"), KINGBASE("KingbaseES"),SYBASE("Sybase"), H2("H2"), SQLITE("SQLite"), HANA("HDB"), MARIADB("MariaDB");

private static final Map<String, DatabaseType> nameMap;

Expand Down