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
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e99a32-1770.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e99a32-1770.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?