Mybatis基础核心类说明

1:  org.apache.ibatis.mapping.ParameterMapping

为Mybatis参数的抽象表示,包括Java类型与数据库类型以及类型处理器属性名字等等!!

例如:

其中id真是参数类型为Long,在mybatis中统一使用Object表示!

 

 

2:org.apache.ibatis.mapping.BoundSql 是XML中配置的某一个方法的SQL的抽象表示,而MappedStatement则是整个Mapper.xml的抽象表示!!!!

该类封装了SQL以及参数信息,其中 parameterObject成员是一个Map数据结构,key/value为参数名字,例如: 

MappedStatement是整个Mapper.xml的抽象表示: 

 

 

3:org.apache.ibatis.executor.statement.StatementHandler 负责设置SQL中的参数的类 ,在具体子类中完成操作!

 其中org.apache.ibatis.executor.statement.PreparedStatementHandler#parameterize方法负责参数的填充,StatementHandler持有一个ParameterHandler成员,底层实现使用的是org.apache.ibatis.executor.parameter.ParameterHandler工具类完成到Statement参数的填充!!!!

 

4:org.apache.ibatis.executor.parameter.ParameterHandler 一个参数Handler设置所有的参数到PreparedStatement中!!!源码说明:

/**
 * A parameter handler sets the parameters of the {@code PreparedStatement}
 *
 * @author Clinton Begin
 */
public interface ParameterHandler {

  Object getParameterObject();

  void setParameters(PreparedStatement ps)
      throws SQLException;

}

  

posted @ 2018-12-06 13:39  bf378  阅读(1163)  评论(0编辑  收藏  举报