BATCH-2771: Fix deprecations in DefaultDataFieldMaxValueIncrementerFactory
This commit is contained in:
committed by
Mahmoud Ben Hassine
parent
76c34c7f72
commit
fa62861015
@@ -10,7 +10,7 @@ batch.schema.script=classpath:/org/springframework/batch/core/schema-postgresql.
|
||||
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-postgresql.sql
|
||||
batch.business.schema.script=classpath:/business-schema-postgresql.sql
|
||||
batch.data.source.init=true
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer
|
||||
batch.database.incrementer.parent=sequenceIncrementerParent
|
||||
batch.grid.size=2
|
||||
batch.verify.cursor.position=true
|
||||
|
||||
@@ -4,7 +4,7 @@ batch.jdbc.driver=org.postgresql.Driver
|
||||
batch.jdbc.url=jdbc:postgresql://localhost/samples
|
||||
batch.jdbc.user=postgres
|
||||
batch.jdbc.password=dba
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer
|
||||
batch.schema.script=classpath:/org/springframework/batch/core/schema-postgresql.sql
|
||||
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-postgresql.sql
|
||||
batch.jdbc.testWhileIdle=false
|
||||
|
||||
@@ -9,6 +9,6 @@ batch.jdbc.validationQuery=
|
||||
batch.schema.script=classpath:org/springframework/batch/item/database/init-foo-schema-postgres.sql
|
||||
batch.business.schema.script=classpath:/org/springframework/batch/jms/init.sql
|
||||
batch.data.source.init=true
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer
|
||||
batch.database.incrementer.parent=sequenceIncrementerParent
|
||||
batch.verify.cursor.position=true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2017 the original author or authors.
|
||||
* Copyright 2006-2018 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.
|
||||
@@ -20,15 +20,15 @@ import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.batch.support.DatabaseType;
|
||||
import org.springframework.jdbc.support.incrementer.DB2MainframeSequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.Db2LuwMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.Db2MainframeMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.H2SequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer;
|
||||
|
||||
@@ -54,6 +54,7 @@ import static org.springframework.batch.support.DatabaseType.SYBASE;
|
||||
*
|
||||
* @author Lucas Ward
|
||||
* @author Michael Minella
|
||||
* @author Drummond Dawson
|
||||
* @see DatabaseType
|
||||
*/
|
||||
public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxValueIncrementerFactory {
|
||||
@@ -63,9 +64,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
|
||||
@@ -83,10 +84,10 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
|
||||
DatabaseType databaseType = DatabaseType.valueOf(incrementerType.toUpperCase());
|
||||
|
||||
if (databaseType == DB2 || databaseType == DB2AS400) {
|
||||
return new DB2SequenceMaxValueIncrementer(dataSource, incrementerName);
|
||||
return new Db2LuwMaxValueIncrementer(dataSource, incrementerName);
|
||||
}
|
||||
else if (databaseType == DB2ZOS) {
|
||||
return new DB2MainframeSequenceMaxValueIncrementer(dataSource, incrementerName);
|
||||
return new Db2MainframeMaxValueIncrementer(dataSource, incrementerName);
|
||||
}
|
||||
else if (databaseType == DERBY) {
|
||||
return new DerbyMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
|
||||
@@ -106,7 +107,7 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
|
||||
return new OracleSequenceMaxValueIncrementer(dataSource, incrementerName);
|
||||
}
|
||||
else if (databaseType == POSTGRES) {
|
||||
return new PostgreSQLSequenceMaxValueIncrementer(dataSource, incrementerName);
|
||||
return new PostgresSequenceMaxValueIncrementer(dataSource, incrementerName);
|
||||
}
|
||||
else if (databaseType == SQLITE) {
|
||||
return new SqliteMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
|
||||
@@ -123,7 +124,7 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
|
||||
@Override
|
||||
public boolean isSupportedIncrementerType(String incrementerType) {
|
||||
for (DatabaseType type : DatabaseType.values()) {
|
||||
if (type.name().equals(incrementerType.toUpperCase())) {
|
||||
if (type.name().equalsIgnoreCase(incrementerType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2008 the original author or authors.
|
||||
* Copyright 2006-2018 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.
|
||||
@@ -21,20 +21,20 @@ import junit.framework.TestCase;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.Db2LuwMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.Db2MainframeMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer;
|
||||
import org.springframework.jdbc.support.incrementer.DB2MainframeSequenceMaxValueIncrementer;
|
||||
|
||||
/**
|
||||
* @author Lucas Ward
|
||||
* @author Will Schipp
|
||||
*
|
||||
* @author Drummond Dawson
|
||||
*/
|
||||
public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase {
|
||||
|
||||
@@ -89,11 +89,11 @@ public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testDb2(){
|
||||
assertTrue(factory.getIncrementer("db2", "NAME") instanceof DB2SequenceMaxValueIncrementer);
|
||||
assertTrue(factory.getIncrementer("db2", "NAME") instanceof Db2LuwMaxValueIncrementer);
|
||||
}
|
||||
|
||||
public void testDb2zos(){
|
||||
assertTrue(factory.getIncrementer("db2zos", "NAME") instanceof DB2MainframeSequenceMaxValueIncrementer);
|
||||
assertTrue(factory.getIncrementer("db2zos", "NAME") instanceof Db2MainframeMaxValueIncrementer);
|
||||
}
|
||||
|
||||
public void testMysql(){
|
||||
@@ -114,7 +114,7 @@ public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testPostgres(){
|
||||
assertTrue(factory.getIncrementer("postgres", "NAME") instanceof PostgreSQLSequenceMaxValueIncrementer);
|
||||
assertTrue(factory.getIncrementer("postgres", "NAME") instanceof PostgresSequenceMaxValueIncrementer);
|
||||
}
|
||||
|
||||
public void testMsSqlServer(){
|
||||
|
||||
@@ -11,7 +11,7 @@ batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-postgres
|
||||
batch.schema.script=classpath:/org/springframework/batch/core/schema-postgresql.sql
|
||||
batch.business.schema.script=business-schema-postgresql.sql
|
||||
batch.data.source.init=true
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
|
||||
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer
|
||||
batch.database.incrementer.parent=sequenceIncrementerParent
|
||||
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
|
||||
batch.grid.size=2
|
||||
|
||||
Reference in New Issue
Block a user