Skip to content

about MyBatisPagingItemReader ibatis ExecutorType #771

Description

@q3356564

use MyBatisPagingItemReader is set default ExecutorType ExecutorType.BATCH

code is

  protected void doReadPage() {
    if (this.sqlSessionTemplate == null) {
          this.sqlSessionTemplate = new SqlSessionTemplate(this.sqlSessionFactory, ExecutorType.BATCH);
    }

    Map<String, Object> parameters = new HashMap();
    if (this.parameterValues != null) {
        parameters.putAll(this.parameterValues);
    }

    parameters.put("_page", this.getPage());
    parameters.put("_pagesize", this.getPageSize());
    parameters.put("_skiprows", this.getPage() * this.getPageSize());
    if (this.results == null) {
        this.results = new CopyOnWriteArrayList();
    } else {
        this.results.clear();
    }

    this.results.addAll(this.sqlSessionTemplate.selectList(this.queryId, parameters));
}

if writer is use another ExecutorType have some erro
the stack is org.springframework.dao.TransientDataAccessResourceException: Cannot change the ExecutorType when there is an existing transaction

Whether to use variables to set ExecutorType

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions