Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need setter method of sqlSessionTemplate in class MyBatisPagingItemReader #601

Open
marszhang-sha opened this issue Aug 4, 2021 · 0 comments

Comments

@marszhang-sha
Copy link

mybatis-spring version

2.0.6

mybatis version

3.5.7

expect

sqlSessionTemplate can be injected

actual

sqlSessionTemplate is private, and there is no setter method

code

@Override
  protected void doReadPage() {
    if (sqlSessionTemplate == null) {
      sqlSessionTemplate = new SqlSessionTemplate(sqlSessionFactory, ExecutorType.BATCH);
    }
    Map<String, Object> parameters = new HashMap<>();
    if (parameterValues != null) {
      parameters.putAll(parameterValues);
    }
    parameters.put("_page", getPage());
    parameters.put("_pagesize", getPageSize());
    parameters.put("_skiprows", getPage() * getPageSize());
    if (results == null) {
      results = new CopyOnWriteArrayList<>();
    } else {
      results.clear();
    }
    results.addAll(sqlSessionTemplate.selectList(queryId, parameters));
  }
@marszhang-sha marszhang-sha changed the title MyBatisPagingItemReader need setter method of sqlSessionTemplate Need setter method of sqlSessionTemplate in class MyBatisPagingItemReader Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant