From bb337c6b2fad4f76b33525863d341e44adbf076a Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 21 Mar 2023 14:42:44 +0100 Subject: [PATCH] Change visibility of properties to protected in JdbcPagingItemReaderBuilder There are cases, when you want to extend the JdbcPagingItemReader by adding some custom fields and behaviours, but want to stay in the normal way of creating this class via a Builder class. If you want to do it, you currently have to reimplement the whole class just for adding some fields because there is no non-ugly way to access the fields. This commit makes those properties protected, so one can override the default build() method behaviour in the derived class and still have access to the properties. Issue #4331 --- .../builder/JdbcPagingItemReaderBuilder.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/builder/JdbcPagingItemReaderBuilder.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/builder/JdbcPagingItemReaderBuilder.java index 2c20b25ff..c34bbedfc 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/builder/JdbcPagingItemReaderBuilder.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/builder/JdbcPagingItemReaderBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2022 the original author or authors. + * Copyright 2017-2023 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. @@ -56,33 +56,33 @@ import org.springframework.util.Assert; */ public class JdbcPagingItemReaderBuilder { - private DataSource dataSource; + protected DataSource dataSource; - private int fetchSize = JdbcPagingItemReader.VALUE_NOT_SET; + protected int fetchSize = JdbcPagingItemReader.VALUE_NOT_SET; - private PagingQueryProvider queryProvider; + protected PagingQueryProvider queryProvider; - private RowMapper rowMapper; + protected RowMapper rowMapper; - private Map parameterValues; + protected Map parameterValues; - private int pageSize = 10; + protected int pageSize = 10; - private String groupClause; + protected String groupClause; - private String selectClause; + protected String selectClause; - private String fromClause; + protected String fromClause; - private String whereClause; + protected String whereClause; - private Map sortKeys; + protected Map sortKeys; - private boolean saveState = true; + protected boolean saveState = true; - private String name; + protected String name; - private int maxItemCount = Integer.MAX_VALUE; + protected int maxItemCount = Integer.MAX_VALUE; private int currentItemCount; @@ -329,7 +329,7 @@ public class JdbcPagingItemReaderBuilder { return reader; } - private PagingQueryProvider determineQueryProvider(DataSource dataSource) { + protected PagingQueryProvider determineQueryProvider(DataSource dataSource) { try { DatabaseType databaseType = DatabaseType.fromMetaData(dataSource); @@ -394,5 +394,4 @@ public class JdbcPagingItemReaderBuilder { throw new IllegalArgumentException("Unable to determine PagingQueryProvider type", e); } } - }