Skip to content

Commit fa62861

Browse files
drumoniifmbenhassine
authored andcommitted
BATCH-2771: Fix deprecations in DefaultDataFieldMaxValueIncrementerFactory
1 parent 76c34c7 commit fa62861

File tree

6 files changed

+24
-23
lines changed

6 files changed

+24
-23
lines changed

spring-batch-core-tests/src/test/resources/batch-postgres.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ batch.schema.script=classpath:/org/springframework/batch/core/schema-postgresql.
1010
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-postgresql.sql
1111
batch.business.schema.script=classpath:/business-schema-postgresql.sql
1212
batch.data.source.init=true
13-
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
13+
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer
1414
batch.database.incrementer.parent=sequenceIncrementerParent
1515
batch.grid.size=2
1616
batch.verify.cursor.position=true

spring-batch-core/src/main/resources/batch-postgresql.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ batch.jdbc.driver=org.postgresql.Driver
44
batch.jdbc.url=jdbc:postgresql://localhost/samples
55
batch.jdbc.user=postgres
66
batch.jdbc.password=dba
7-
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
7+
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer
88
batch.schema.script=classpath:/org/springframework/batch/core/schema-postgresql.sql
99
batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-postgresql.sql
1010
batch.jdbc.testWhileIdle=false

spring-batch-infrastructure-tests/src/test/resources/batch-postgres.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ batch.jdbc.validationQuery=
99
batch.schema.script=classpath:org/springframework/batch/item/database/init-foo-schema-postgres.sql
1010
batch.business.schema.script=classpath:/org/springframework/batch/jms/init.sql
1111
batch.data.source.init=true
12-
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
12+
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer
1313
batch.database.incrementer.parent=sequenceIncrementerParent
1414
batch.verify.cursor.position=true

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactory.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2017 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,15 +20,15 @@
2020
import javax.sql.DataSource;
2121

2222
import org.springframework.batch.support.DatabaseType;
23-
import org.springframework.jdbc.support.incrementer.DB2MainframeSequenceMaxValueIncrementer;
24-
import org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer;
23+
import org.springframework.jdbc.support.incrementer.Db2LuwMaxValueIncrementer;
24+
import org.springframework.jdbc.support.incrementer.Db2MainframeMaxValueIncrementer;
2525
import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;
2626
import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer;
2727
import org.springframework.jdbc.support.incrementer.H2SequenceMaxValueIncrementer;
2828
import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer;
2929
import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer;
3030
import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer;
31-
import org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer;
31+
import org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer;
3232
import org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer;
3333
import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer;
3434

@@ -54,6 +54,7 @@
5454
*
5555
* @author Lucas Ward
5656
* @author Michael Minella
57+
* @author Drummond Dawson
5758
* @see DatabaseType
5859
*/
5960
public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxValueIncrementerFactory {
@@ -63,9 +64,9 @@ public class DefaultDataFieldMaxValueIncrementerFactory implements DataFieldMaxV
6364
private String incrementerColumnName = "ID";
6465

6566
/**
66-
- * Public setter for the column name (defaults to "ID") in the incrementer.
67-
- * Only used by some platforms (Derby, HSQL, MySQL, SQL Server and Sybase),
68-
- * and should be fine for use with Spring Batch meta data as long as the
67+
* Public setter for the column name (defaults to "ID") in the incrementer.
68+
* Only used by some platforms (Derby, HSQL, MySQL, SQL Server and Sybase),
69+
* and should be fine for use with Spring Batch meta data as long as the
6970
* default batch schema hasn't been changed.
7071
*
7172
* @param incrementerColumnName the primary key column name to set
@@ -83,10 +84,10 @@ public DataFieldMaxValueIncrementer getIncrementer(String incrementerType, Strin
8384
DatabaseType databaseType = DatabaseType.valueOf(incrementerType.toUpperCase());
8485

8586
if (databaseType == DB2 || databaseType == DB2AS400) {
86-
return new DB2SequenceMaxValueIncrementer(dataSource, incrementerName);
87+
return new Db2LuwMaxValueIncrementer(dataSource, incrementerName);
8788
}
8889
else if (databaseType == DB2ZOS) {
89-
return new DB2MainframeSequenceMaxValueIncrementer(dataSource, incrementerName);
90+
return new Db2MainframeMaxValueIncrementer(dataSource, incrementerName);
9091
}
9192
else if (databaseType == DERBY) {
9293
return new DerbyMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
@@ -106,7 +107,7 @@ else if (databaseType == ORACLE) {
106107
return new OracleSequenceMaxValueIncrementer(dataSource, incrementerName);
107108
}
108109
else if (databaseType == POSTGRES) {
109-
return new PostgreSQLSequenceMaxValueIncrementer(dataSource, incrementerName);
110+
return new PostgresSequenceMaxValueIncrementer(dataSource, incrementerName);
110111
}
111112
else if (databaseType == SQLITE) {
112113
return new SqliteMaxValueIncrementer(dataSource, incrementerName, incrementerColumnName);
@@ -123,7 +124,7 @@ else if (databaseType == SYBASE) {
123124
@Override
124125
public boolean isSupportedIncrementerType(String incrementerType) {
125126
for (DatabaseType type : DatabaseType.values()) {
126-
if (type.name().equals(incrementerType.toUpperCase())) {
127+
if (type.name().equalsIgnoreCase(incrementerType)) {
127128
return true;
128129
}
129130
}

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/support/DefaultDataFieldMaxValueIncrementerFactoryTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2006-2008 the original author or authors.
2+
* Copyright 2006-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,20 +21,20 @@
2121

2222
import static org.mockito.Mockito.mock;
2323

24-
import org.springframework.jdbc.support.incrementer.DB2SequenceMaxValueIncrementer;
24+
import org.springframework.jdbc.support.incrementer.Db2LuwMaxValueIncrementer;
25+
import org.springframework.jdbc.support.incrementer.Db2MainframeMaxValueIncrementer;
2526
import org.springframework.jdbc.support.incrementer.DerbyMaxValueIncrementer;
2627
import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer;
2728
import org.springframework.jdbc.support.incrementer.MySQLMaxValueIncrementer;
2829
import org.springframework.jdbc.support.incrementer.OracleSequenceMaxValueIncrementer;
29-
import org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer;
30+
import org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer;
3031
import org.springframework.jdbc.support.incrementer.SqlServerMaxValueIncrementer;
3132
import org.springframework.jdbc.support.incrementer.SybaseMaxValueIncrementer;
32-
import org.springframework.jdbc.support.incrementer.DB2MainframeSequenceMaxValueIncrementer;
3333

3434
/**
3535
* @author Lucas Ward
3636
* @author Will Schipp
37-
*
37+
* @author Drummond Dawson
3838
*/
3939
public class DefaultDataFieldMaxValueIncrementerFactoryTests extends TestCase {
4040

@@ -89,11 +89,11 @@ public void testNullIncrementerName(){
8989
}
9090

9191
public void testDb2(){
92-
assertTrue(factory.getIncrementer("db2", "NAME") instanceof DB2SequenceMaxValueIncrementer);
92+
assertTrue(factory.getIncrementer("db2", "NAME") instanceof Db2LuwMaxValueIncrementer);
9393
}
9494

9595
public void testDb2zos(){
96-
assertTrue(factory.getIncrementer("db2zos", "NAME") instanceof DB2MainframeSequenceMaxValueIncrementer);
96+
assertTrue(factory.getIncrementer("db2zos", "NAME") instanceof Db2MainframeMaxValueIncrementer);
9797
}
9898

9999
public void testMysql(){
@@ -114,7 +114,7 @@ public void testHsql(){
114114
}
115115

116116
public void testPostgres(){
117-
assertTrue(factory.getIncrementer("postgres", "NAME") instanceof PostgreSQLSequenceMaxValueIncrementer);
117+
assertTrue(factory.getIncrementer("postgres", "NAME") instanceof PostgresSequenceMaxValueIncrementer);
118118
}
119119

120120
public void testMsSqlServer(){

spring-batch-samples/src/main/resources/batch-postgresql.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ batch.drop.script=classpath:/org/springframework/batch/core/schema-drop-postgres
1111
batch.schema.script=classpath:/org/springframework/batch/core/schema-postgresql.sql
1212
batch.business.schema.script=business-schema-postgresql.sql
1313
batch.data.source.init=true
14-
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgreSQLSequenceMaxValueIncrementer
14+
batch.database.incrementer.class=org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer
1515
batch.database.incrementer.parent=sequenceIncrementerParent
1616
batch.lob.handler.class=org.springframework.jdbc.support.lob.DefaultLobHandler
1717
batch.grid.size=2

0 commit comments

Comments
 (0)