spring-projects / spring-projects/spring-batch

JdbcPagingItemReader constructor injection of JdbcTemplate instance

Open Beginner friendly
#5,485 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: infrastructure type: feature
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

Provide a new JdbcPagingItemReader constructor for JdbcTemplate instance injection. That would be useful to intercept JdbcOperations calls through AOP.

Current implementation:

    @Override
	public void afterPropertiesSet() throws Exception {
		super.afterPropertiesSet();
		JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
		if (fetchSize != VALUE_NOT_SET) {
			jdbcTemplate.setFetchSize(fetchSize);
		}
		jdbcTemplate.setMaxRows(getPageSize());
		namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
		queryProvider.init(dataSource);
		this.firstPageSql = queryProvider.generateFirstPageQuery(getPageSize());
		this.remainingPagesSql = queryProvider.generateRemainingPagesQuery(getPageSize());
	}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with JdbcPagingItemReader and its afterPropertiesSet implementation shown in the issue. Trace how the JdbcTemplate and NamedParameterJdbcTemplate are initialized, then add the requested constructor injection while preserving the existing setup behavior. Done means callers can provide a JdbcTemplate instance for intercepting JdbcOperations calls through AOP.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, database
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.