Error in batch query encapsulated with Mybatis Plus

< H1 > error using Mybatis Plus encapsulated batch query < / H1 > < H2 > Environment < / H2 >
  • JDK 1.8
  • Spring Boot 2.0.6.RELEASE
  • mybatis-plus-boot-starter 2.3
< H2 > scene < / H2 >

We need to encapsulate a general method that can be queried according to the list of objects, so we write the following method
Note: this class inherits IServiceImpl

  about custom global injection, how to operate wrapper as a parameter. , but in a different way, we don"t define interfaces in  BaseDao  at all. 

Jul.12,2022

misread the newspaper

There is no getter for property named 'ew' in' class com.baomidou.mybatisplus.mapper.EntityWrapper'

you have written an attribute called ew in your configuration file. Look for it, but there is no corresponding getEw () method in the corresponding entity class

.

provide the mybatis-plus version number you use.


official developers replied StackOverflow .

public List<T> listBatchByEntityList(List<T> entityList) {
    try (final SqlSession batchSqlSession = sqlSessionBatch()) {
        final int size = entityList.size();
        final int batchSize = 30;
        final List<T> result = new ArrayList<>();
        for (int i = 0; i < size; iPP) {
            final String sqlStatement = sqlStatement(SqlMethod.SELECT_LIST);
            final Map<String, Object> param = new MapperMethod.ParamMap<Object>();
            EntityWrapper<T> ew = new EntityWrapper<>(entityList.get(i));
            param.put("ew", ew);
            param.put("param1", ew);
            final List<T> list = batchSqlSession.selectList(sqlStatement, param);
            result.addAll(list);
            if (i >= 1 && i % batchSize == 0) {
                batchSqlSession.flushStatements();
            }
        }
        batchSqlSession.flushStatements();
        return result;
    } catch (Exception e) {
        throw new GlobalException("Error: Cannot execute listBatchByEntityList Method. Cause", e);
    }
}
attachment: we have not measured the answer
Menu