Error querying database. Cause: java.util.ConcurrentModificationException

Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.util.ConcurrentModificationException
### Cause: java.util.ConcurrentModificationException
at org.apache.ibatis.exceptions.ExceptionFac

For the iterative stability problem, it is used for database query. The value of lastbyparam.getid is re assigned to ID, and an error is reported due to the reference of the object; Another problem is that valueconfig is the value obtained from Nacos. The global variable cannot always add ID, and the collection will slowly grow

List<Long> Ids = valueConfig.getIds();
Ids.add(Id);
ObjectDO lastByParam = testMapper.getLastByParam(userId, Ids, null);
if (lastByParam != null){
    Id = lastByParam.getId();
}

The solution is to re new a collection

Read More: