xml文件示例如下:${parameter}
orgapacheibatisexecutorstatementRoutingStatementHandler.java源码如下:
public RoutingStatementHandler(Executor executor, MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler, BoundSql boundSql) {
switch (ms.getStatementType()) {
case STATEMENT:
delegate = new SimpleStatementHandler(executor, ms, parameter, rowBounds, resultHandler, boundSql);
break;
case PREPARED:
delegate = new PreparedStatementHandler(executor, ms, parameter, rowBounds, resultHandler, boundSql);
break;
case CALLABLE:
delegate = new CallableStatementHandler(executor, ms, parameter, rowBounds, resultHandler, boundSql);
break;
default:
throw new ExecutorException("Unknown statement type: " + ms.getStatementType());
}
}
由xml配置文件和源码文件可知,根据statementType来判断执行哪个方法。
取值说明:
1、STATEMENT:直接操作sql,不进行预编译,获取数据:$—Statement ,如果这个时候使用占位符的话,就会报错,执行sql异常,因为不能翻译占位符,如select * from student limit ? ,不能正确执行,应该换成PREPARED这种就好了
2、PREPARED:预处理,参数,进行预编译,获取数据:#—–PreparedStatement:默认
3、CALLABLE:执行存储过程————CallableStatement



