当前使用版本(必填,否则不予处理)

org.apache.ibatis.executor.statement.BaseStatementHandler#BaseStatementHandler protected BaseStatementHandler(Executor executor, MappedStatement mappedStatement, Object parameterObject, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) { this.configuration = mappedStatement.getConfiguration(); this.executor = executor; this.mappedStatement = mappedStatement; this.rowBounds = rowBounds;

this.typeHandlerRegistry = configuration.getTypeHandlerRegistry();
this.objectFactory = configuration.getObjectFactory();

if (boundSql == null) { // issue #435, get the key before calculating the statement
  generateKeys(parameterObject);
  boundSql = mappedStatement.getBoundSql(parameterObject);
}
_**// 已经根据参数构造sql语句
this.boundSql = boundSql;**_

 **_// 此处调用参数的填充逻辑,但此时sql语句已经生成,填充的字段不会传参到sql语句中
this.parameterHandler = configuration.newParameterHandler(mappedStatement, parameterObject, boundSql);_**
this.resultSetHandler = configuration.newResultSetHandler(executor, mappedStatement, rowBounds, parameterHandler, resultHandler, boundSql);

}

该问题是如何引起的?(确定最新版也有问题再提!!!)

由于给实体填充一些用户ID字段,但当用户没有登录时无法获取用户id,修改Insert的逻辑,去掉字段填充时不添加的判断。

字段填充是否考虑应该在boundSql生成之前执行。

重现步骤(如果有就写完整)

报错信息

Comment From: qmdx

底层 mybatis 限制使然,无法支持你的需求,你可以指定一个不存在的 id 值比如 0