今天主要讲MapperMethod类。
public class MapperMethod {
// sql命令对象,也就是解析sql语句用,对应我们的xml中的sql语句
private final SqlCommand command;
//方法签名 对应我们定义在接口中方法,比如 :public User selectUser(String id);
private final MethodSignature method;
public MapperMethod(Class<?> mapperInterface, Method method, Configuration config) {
this.command = new SqlCommand(config, mapperInterface, method);
this.method = new MethodSignature(config, mapperInterface, method);
}
// 省略无数行 ;;;
}
看我的注释之后,这个类其实很简单,就是做xml中sql和java类中方法的管理的。
这里说个题外话:为什么MyBatis中不支持同一个statementId出现重复,或者说为什么对应的Mapper接口定义中,我