Add support for DB2AS400 database
Add support for DB2AS400 to DefaultDataFieldMaxValueIncrementerFactory. Apparently, DB2AS400 is using the same syntax for sequence value retrieval as standard DB2. resolves BATCH-2525
This commit is contained in:
committed by
Michael Minella
parent
509be945fc
commit
8402f10242
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer
|
||||
import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer;
|
||||
|
||||
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;
|
||||
@@ -62,9 +63,9 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
|
||||
private String incrementerColumnName = "ID";
|
||||
|
||||
/**
|
||||
* Public setter for the column name (defaults to "ID") in the incrementer.
|
||||
* Only used by some platforms (Derby, HSQL, MySQL, SQL Server and Sybase),
|
||||
* and should be fine for use with Spring Batch meta data as long as the
|
||||
- * Public setter for the column name (defaults to "ID") in the incrementer.
|
||||
- * Only used by some platforms (Derby, HSQL, MySQL, SQL Server and Sybase),
|
||||
- * and should be fine for use with Spring Batch meta data as long as the
|
||||
* default batch schema hasn't been changed.
|
||||
*
|
||||
* @param incrementerColumnName the primary key column name to set
|
||||
@@ -77,11 +78,11 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public DataFieldMaxValueIncrementer getIncrementer(String incrementerType, String incrementerName) {
|
||||
DatabaseType databaseType = DatabaseType.valueOf(incrementerType.toUpperCase());
|
||||
|
||||
if (databaseType == DB2) {
|
||||
if (databaseType == DB2 || databaseType == DB2AS400) {
|
||||
return new DB2SequenceMaxValueIncrementer(dataSource, incrementerName);
|
||||
}
|
||||
else if (databaseType == DB2ZOS) {
|
||||
@@ -117,9 +118,8 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
|
||||
return new SybaseMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
|
||||
}
|
||||
throw new IllegalArgumentException("databaseType argument was not on the approved list");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSupportedIncrementerType(String incrementerType) {
|
||||
for (DatabaseType type : DatabaseType.values()) {
|
||||
@@ -134,7 +134,7 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
|
||||
@Override
|
||||
public String[] getSupportedIncrementerTypes() {
|
||||
|
||||
List<String> types = new ArrayList<String>();
|
||||
List<String> types = new ArrayList<>();
|
||||
|
||||
for (DatabaseType type : DatabaseType.values()) {
|
||||
types.add(type.name());
|
||||
@@ -142,4 +142,4 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
|
||||
|
||||
return types.toArray(new String[types.size()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user