org.apache.ibatis.annotations.Options#org.apache.ibatis.executor.keygen.NoKeyGenerator源码实例Demo

下面列出了org.apache.ibatis.annotations.Options#org.apache.ibatis.executor.keygen.NoKeyGenerator 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mybaties   文件: MappedStatement.java
public Builder(Configuration configuration, String id, SqlSource sqlSource, SqlCommandType sqlCommandType) {
  mappedStatement.configuration = configuration;
  mappedStatement.id = id;
  mappedStatement.sqlSource = sqlSource;
  mappedStatement.statementType = StatementType.PREPARED;
  mappedStatement.parameterMap = new ParameterMap.Builder(configuration, "defaultParameterMap", null, new ArrayList<ParameterMapping>()).build();
  mappedStatement.resultMaps = new ArrayList<ResultMap>();
  mappedStatement.timeout = configuration.getDefaultStatementTimeout();
  mappedStatement.sqlCommandType = sqlCommandType;
  mappedStatement.keyGenerator = configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType) ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
  String logId = id;
  if (configuration.getLogPrefix() != null) {
    logId = configuration.getLogPrefix() + id;
  }
  mappedStatement.statementLog = LogFactory.getLog(logId);
  mappedStatement.lang = configuration.getDefaultScriptingLanuageInstance();
}
 
源代码2 项目: mybatis   文件: MappedStatement.java
public Builder(Configuration configuration, String id, SqlSource sqlSource, SqlCommandType sqlCommandType) {
  mappedStatement.configuration = configuration;
  mappedStatement.id = id;
  mappedStatement.sqlSource = sqlSource;
  mappedStatement.statementType = StatementType.PREPARED;
  mappedStatement.parameterMap = new ParameterMap.Builder(configuration, "defaultParameterMap", null, new ArrayList<ParameterMapping>()).build();
  mappedStatement.resultMaps = new ArrayList<ResultMap>();
  mappedStatement.timeout = configuration.getDefaultStatementTimeout();
  mappedStatement.sqlCommandType = sqlCommandType;
  mappedStatement.keyGenerator = configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType) ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
  String logId = id;
  if (configuration.getLogPrefix() != null) {
    logId = configuration.getLogPrefix() + id;
  }
  mappedStatement.statementLog = LogFactory.getLog(logId);
  mappedStatement.lang = configuration.getDefaultScriptingLanuageInstance();
}
 
源代码3 项目: Roothub   文件: SelectOne.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod selectOne = SqlMethod.SELECT_ONE;
    String sqlScript = String.format(selectOne.getSql(), tableInfo.getSelectColumnSegments(true),
            tableInfo.getTableName(), getWrapperScript());
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, selectOne.getMethod(), sqlSource, SqlCommandType.SELECT, String.class, null, modelClass, new NoKeyGenerator(), tableInfo.getKeyProperty(), tableInfo.getKeyColumn());
}
 
源代码4 项目: Roothub   文件: DeleteById.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod deleteById = SqlMethod.DELETE_BY_ID;
    String sqlScript = String.format(deleteById.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(), "#{id}");
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, deleteById.getMethod(), sqlSource, SqlCommandType.DELETE, String.class, null, Integer.class, new NoKeyGenerator(), tableInfo.getKeyProperty(), tableInfo.getKeyColumn());
}
 
源代码5 项目: Roothub   文件: Delete.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod delete = SqlMethod.DELETE;
    String sqlScript = String.format(delete.getSql(), tableInfo.getTableName(), getWrapperScript());
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, delete.getMethod(), sqlSource, SqlCommandType.DELETE, String.class, null, Integer.class, new NoKeyGenerator(), tableInfo.getKeyProperty(), tableInfo.getKeyColumn());
}
 
源代码6 项目: Roothub   文件: Insert.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod insert = SqlMethod.INSERT;
    String sqlScript = String.format(insert.getSql(), tableInfo.getTableName(), tableInfo.getInsertColumnSegments(), tableInfo.getInsertValueSegments());
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, insert.getMethod(), sqlSource, SqlCommandType.INSERT, String.class, null, Integer.class, new NoKeyGenerator(), tableInfo.getKeyProperty(), tableInfo.getKeyColumn());
}
 
源代码7 项目: Roothub   文件: SelectList.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod selectList = SqlMethod.SELECT_LIST;
    String sqlScript = String.format(selectList.getSql(), tableInfo.getSelectColumnSegments(true),
            tableInfo.getTableName(), getWrapperScript());
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, selectList.getMethod(), sqlSource, SqlCommandType.SELECT, String.class, null, modelClass, new NoKeyGenerator(), null, tableInfo.getKeyColumn());
}
 
源代码8 项目: Roothub   文件: Update.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod update = SqlMethod.UPDATE;
    String sqlScript = String.format(update.getSql(), tableInfo.getTableName(), tableInfo.getSetSegments(), getWrapperScript());
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, update.getMethod(), sqlSource, SqlCommandType.UPDATE, String.class, null, Integer.class, new NoKeyGenerator(), tableInfo.getKeyProperty(), tableInfo.getKeyColumn());
}
 
源代码9 项目: Roothub   文件: UpdateById.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod updateById = SqlMethod.UPDATE_BY_ID;
    String sqlScript = String.format(updateById.getSql(), tableInfo.getTableName(), tableInfo.getSetSegments(),
            tableInfo.getKeyColumn(), tableInfo.getKeyPropertySegment());
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, updateById.getMethod(), sqlSource, SqlCommandType.UPDATE, String.class, null, Integer.class, new NoKeyGenerator(), tableInfo.getKeyProperty(), tableInfo.getKeyColumn());
}
 
源代码10 项目: Roothub   文件: SelectById.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod selectById = SqlMethod.SELECT_BY_ID;
    String sqlScript = String.format(selectById.getSql(), tableInfo.getSelectColumnSegments(false),
            tableInfo.getTableName(), tableInfo.getKeyColumn(), "#{id}");
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, selectById.getMethod(), sqlSource, SqlCommandType.SELECT, null, null, modelClass, new NoKeyGenerator(), tableInfo.getKeyProperty(), tableInfo.getKeyColumn());
}
 
源代码11 项目: Roothub   文件: DeleteBatchIds.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod deleteBatchByIds = SqlMethod.DELETE_BATCH_BY_IDS;
    String sqlScript = String.format(deleteBatchByIds.getSql(), tableInfo.getTableName(), tableInfo.getKeyColumn(), getIdsScript());
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, deleteBatchByIds.getMethod(), sqlSource, SqlCommandType.DELETE, String.class, null, Integer.class, new NoKeyGenerator(), tableInfo.getKeyProperty(), tableInfo.getKeyColumn());
}
 
源代码12 项目: Roothub   文件: SelectBatchIds.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod selectBatchByIds = SqlMethod.SELECT_BATCH_BY_IDS;
    String sqlScript = String.format(selectBatchByIds.getSql(), tableInfo.getSelectColumnSegments(false),
            tableInfo.getTableName(), tableInfo.getKeyColumn(), getIdsScript());
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, selectBatchByIds.getMethod(), sqlSource, SqlCommandType.SELECT, String.class, null, modelClass, new NoKeyGenerator(), null, tableInfo.getKeyColumn());
}
 
源代码13 项目: Roothub   文件: SelectCount.java
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
    SqlMethod selectCount = SqlMethod.SELECT_COUNT;
    String sqlScript = String.format(selectCount.getSql(), tableInfo.getTableName(), getNormalSqlSegment());
    SqlSource sqlSource = this.languageDriver.createSqlSource(this.configuration, sqlScript, modelClass);
    return this.addMappedStatement(mapperClass, selectCount.getMethod(), sqlSource, SqlCommandType.SELECT, String.class, null, Integer.class, new NoKeyGenerator(), null, tableInfo.getKeyColumn());
}
 
源代码14 项目: azeroth   文件: InsertBuilder.java
/**
 * @param configuration
 * @param entity
 */
public static void build(Configuration configuration, LanguageDriver languageDriver, EntityInfo entity) {

    String[] names = GeneralSqlGenerator.methodDefines.insertName().split(",");
    for (String name : names) {
        String msId = entity.getMapperClass().getName() + "." + name;

        // 从参数对象里提取注解信息
        EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
        // 生成sql
        String sql = buildInsertSql(entityMapper, name.endsWith("Selective"));

        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());

        MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource, SqlCommandType.INSERT);

        KeyGenerator keyGenerator = entityMapper.autoId() ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
        statementBuilder.keyGenerator(keyGenerator)//
                .keyProperty(entityMapper.getIdColumn().getProperty())//
                .keyColumn(entityMapper.getIdColumn().getColumn());

        MappedStatement statement = statementBuilder.build();

        configuration.addMappedStatement(statement);
    }

}
 
源代码15 项目: jeesuite-libs   文件: AbstractMethodBuilder.java
public void build(Configuration configuration, LanguageDriver languageDriver,EntityInfo entity) {
	
	for (String name : methodNames()) {			
		String msId = entity.getMapperClass().getName() + "." + name;
		
		// 从参数对象里提取注解信息
		EntityMapper entityMapper = EntityHelper.getEntityMapper(entity.getEntityClass());
		// 生成sql
		String sql = buildSQL(entityMapper,name.endsWith("Selective"));
		
		SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, entity.getEntityClass());
		
		MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, msId, sqlSource,sqlCommandType());
		
		//主键策略
		if(sqlCommandType() == SqlCommandType.INSERT){
			KeyGenerator keyGenerator = entityMapper.autoId() ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
			statementBuilder.keyGenerator(keyGenerator)//
	                        .keyProperty(entityMapper.getIdColumn().getProperty())//
	                        .keyColumn(entityMapper.getIdColumn().getColumn());
		}
		
		MappedStatement statement = statementBuilder.build();
		//
		setResultType(configuration, statement, entity.getEntityClass());
		configuration.addMappedStatement(statement);
	}
	
}
 
源代码16 项目: mybaties   文件: MapperAnnotationBuilder.java
private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
  String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
  Class<?> resultTypeClass = selectKeyAnnotation.resultType();
  StatementType statementType = selectKeyAnnotation.statementType();
  String keyProperty = selectKeyAnnotation.keyProperty();
  String keyColumn = selectKeyAnnotation.keyColumn();
  boolean executeBefore = selectKeyAnnotation.before();

  // defaults
  boolean useCache = false;
  KeyGenerator keyGenerator = new NoKeyGenerator();
  Integer fetchSize = null;
  Integer timeout = null;
  boolean flushCache = false;
  String parameterMap = null;
  String resultMap = null;
  ResultSetType resultSetTypeEnum = null;

  SqlSource sqlSource = buildSqlSourceFromStrings(selectKeyAnnotation.statement(), parameterTypeClass, languageDriver);
  SqlCommandType sqlCommandType = SqlCommandType.SELECT;

  assistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType, fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass, resultSetTypeEnum,
      flushCache, useCache, false,
      keyGenerator, keyProperty, keyColumn, null, languageDriver, null);

  id = assistant.applyCurrentNamespace(id, false);

  MappedStatement keyStatement = configuration.getMappedStatement(id, false);
  SelectKeyGenerator answer = new SelectKeyGenerator(keyStatement, executeBefore);
  configuration.addKeyGenerator(id, answer);
  return answer;
}
 
源代码17 项目: mybaties   文件: XMLStatementBuilder.java
private void parseSelectKeyNode(String id, XNode nodeToHandle, Class<?> parameterTypeClass, LanguageDriver langDriver, String databaseId) {
  String resultType = nodeToHandle.getStringAttribute("resultType");
  Class<?> resultTypeClass = resolveClass(resultType);
  StatementType statementType = StatementType.valueOf(nodeToHandle.getStringAttribute("statementType", StatementType.PREPARED.toString()));
  String keyProperty = nodeToHandle.getStringAttribute("keyProperty");
  String keyColumn = nodeToHandle.getStringAttribute("keyColumn");
  boolean executeBefore = "BEFORE".equals(nodeToHandle.getStringAttribute("order", "AFTER"));

  //defaults
  boolean useCache = false;
  boolean resultOrdered = false;
  KeyGenerator keyGenerator = new NoKeyGenerator();
  Integer fetchSize = null;
  Integer timeout = null;
  boolean flushCache = false;
  String parameterMap = null;
  String resultMap = null;
  ResultSetType resultSetTypeEnum = null;

  SqlSource sqlSource = langDriver.createSqlSource(configuration, nodeToHandle, parameterTypeClass);
  SqlCommandType sqlCommandType = SqlCommandType.SELECT;

  builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
      fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
      resultSetTypeEnum, flushCache, useCache, resultOrdered,
      keyGenerator, keyProperty, keyColumn, databaseId, langDriver, null);

  id = builderAssistant.applyCurrentNamespace(id, false);

  MappedStatement keyStatement = configuration.getMappedStatement(id, false);
  configuration.addKeyGenerator(id, new SelectKeyGenerator(keyStatement, executeBefore));
}
 
源代码18 项目: mybatis   文件: MapperAnnotationBuilder.java
private KeyGenerator handleSelectKeyAnnotation(SelectKey selectKeyAnnotation, String baseStatementId, Class<?> parameterTypeClass, LanguageDriver languageDriver) {
  String id = baseStatementId + SelectKeyGenerator.SELECT_KEY_SUFFIX;
  Class<?> resultTypeClass = selectKeyAnnotation.resultType();
  StatementType statementType = selectKeyAnnotation.statementType();
  String keyProperty = selectKeyAnnotation.keyProperty();
  String keyColumn = selectKeyAnnotation.keyColumn();
  boolean executeBefore = selectKeyAnnotation.before();

  // defaults
  boolean useCache = false;
  KeyGenerator keyGenerator = new NoKeyGenerator();
  Integer fetchSize = null;
  Integer timeout = null;
  boolean flushCache = false;
  String parameterMap = null;
  String resultMap = null;
  ResultSetType resultSetTypeEnum = null;

  SqlSource sqlSource = buildSqlSourceFromStrings(selectKeyAnnotation.statement(), parameterTypeClass, languageDriver);
  SqlCommandType sqlCommandType = SqlCommandType.SELECT;

  assistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType, fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass, resultSetTypeEnum,
      flushCache, useCache, false,
      keyGenerator, keyProperty, keyColumn, null, languageDriver, null);

  id = assistant.applyCurrentNamespace(id, false);

  MappedStatement keyStatement = configuration.getMappedStatement(id, false);
  SelectKeyGenerator answer = new SelectKeyGenerator(keyStatement, executeBefore);
  configuration.addKeyGenerator(id, answer);
  return answer;
}
 
源代码19 项目: mybatis   文件: XMLStatementBuilder.java
private void parseSelectKeyNode(String id, XNode nodeToHandle, Class<?> parameterTypeClass, LanguageDriver langDriver, String databaseId) {
  String resultType = nodeToHandle.getStringAttribute("resultType");
  Class<?> resultTypeClass = resolveClass(resultType);
  StatementType statementType = StatementType.valueOf(nodeToHandle.getStringAttribute("statementType", StatementType.PREPARED.toString()));
  String keyProperty = nodeToHandle.getStringAttribute("keyProperty");
  String keyColumn = nodeToHandle.getStringAttribute("keyColumn");
  boolean executeBefore = "BEFORE".equals(nodeToHandle.getStringAttribute("order", "AFTER"));

  //defaults
  boolean useCache = false;
  boolean resultOrdered = false;
  KeyGenerator keyGenerator = new NoKeyGenerator();
  Integer fetchSize = null;
  Integer timeout = null;
  boolean flushCache = false;
  String parameterMap = null;
  String resultMap = null;
  ResultSetType resultSetTypeEnum = null;

  SqlSource sqlSource = langDriver.createSqlSource(configuration, nodeToHandle, parameterTypeClass);
  SqlCommandType sqlCommandType = SqlCommandType.SELECT;

  builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
      fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
      resultSetTypeEnum, flushCache, useCache, resultOrdered,
      keyGenerator, keyProperty, keyColumn, databaseId, langDriver, null);

  id = builderAssistant.applyCurrentNamespace(id, false);

  MappedStatement keyStatement = configuration.getMappedStatement(id, false);
  configuration.addKeyGenerator(id, new SelectKeyGenerator(keyStatement, executeBefore));
}
 
protected void addMappedStatement(String id, String[] sqls,
		SqlCommandType sqlCommandType) {

	addMappedStatement(id, sqls, sqlCommandType, null, null, null,
			NoKeyGenerator.INSTANCE, null, null);
}
 
protected void addMappedStatement(String id, String[] sqls,
		SqlCommandType sqlCommandType, Class<?> parameterType) {

	addMappedStatement(id, sqls, sqlCommandType, parameterType, null, null,
			NoKeyGenerator.INSTANCE, null, null);
}
 
protected void addMappedStatement(String id, String[] sqls,
		SqlCommandType sqlCommandType, Class<?> parameterType, Class<?> resultType) {

	addMappedStatement(id, sqls, sqlCommandType, parameterType, null, resultType,
			NoKeyGenerator.INSTANCE, null, null);
}
 
protected void addMappedStatement(String id, String[] sqls,
		SqlCommandType sqlCommandType, Class<?> parameterType, String resultMap) {

	addMappedStatement(id, sqls, sqlCommandType, parameterType, resultMap, null,
			NoKeyGenerator.INSTANCE, null, null);
}
 
源代码24 项目: mybaties   文件: XMLStatementBuilder.java
public void parseStatementNode() {
   String id = context.getStringAttribute("id");
   String databaseId = context.getStringAttribute("databaseId");

   //如果databaseId不匹配,退出
   if (!databaseIdMatchesCurrent(id, databaseId, this.requiredDatabaseId)) {
     return;
   }

   //暗示驱动程序每次批量返回的结果行数
   Integer fetchSize = context.getIntAttribute("fetchSize");
   //超时时间
   Integer timeout = context.getIntAttribute("timeout");
   //引用外部 parameterMap,已废弃
   String parameterMap = context.getStringAttribute("parameterMap");
   //参数类型
   String parameterType = context.getStringAttribute("parameterType");
   Class<?> parameterTypeClass = resolveClass(parameterType);
   //引用外部的 resultMap(高级功能)
   String resultMap = context.getStringAttribute("resultMap");
   //结果类型
   String resultType = context.getStringAttribute("resultType");
   //脚本语言,mybatis3.2的新功能
   String lang = context.getStringAttribute("lang");
   //得到语言驱动
   LanguageDriver langDriver = getLanguageDriver(lang);

   Class<?> resultTypeClass = resolveClass(resultType);
   //结果集类型,FORWARD_ONLY|SCROLL_SENSITIVE|SCROLL_INSENSITIVE 中的一种
   String resultSetType = context.getStringAttribute("resultSetType");
   //语句类型, STATEMENT|PREPARED|CALLABLE 的一种
   StatementType statementType = StatementType.valueOf(context.getStringAttribute("statementType", StatementType.PREPARED.toString()));
   ResultSetType resultSetTypeEnum = resolveResultSetType(resultSetType);

   //获取命令类型(select|insert|update|delete)
   String nodeName = context.getNode().getNodeName();
   SqlCommandType sqlCommandType = SqlCommandType.valueOf(nodeName.toUpperCase(Locale.ENGLISH));
   boolean isSelect = sqlCommandType == SqlCommandType.SELECT;
   boolean flushCache = context.getBooleanAttribute("flushCache", !isSelect);
   //是否要缓存select结果
   boolean useCache = context.getBooleanAttribute("useCache", isSelect);
   //仅针对嵌套结果 select 语句适用:如果为 true,就是假设包含了嵌套结果集或是分组了,这样的话当返回一个主结果行的时候,就不会发生有对前面结果集的引用的情况。
   //这就使得在获取嵌套的结果集的时候不至于导致内存不够用。默认值:false。 
   boolean resultOrdered = context.getBooleanAttribute("resultOrdered", false);

   // Include Fragments before parsing
   //解析之前先解析<include>SQL片段
   XMLIncludeTransformer includeParser = new XMLIncludeTransformer(configuration, builderAssistant);
   includeParser.applyIncludes(context.getNode());

   // Parse selectKey after includes and remove them.
   //解析之前先解析<selectKey>
   processSelectKeyNodes(id, parameterTypeClass, langDriver);
   
   // Parse the SQL (pre: <selectKey> and <include> were parsed and removed)
   //解析成SqlSource,一般是DynamicSqlSource
   SqlSource sqlSource = langDriver.createSqlSource(configuration, context, parameterTypeClass);
   String resultSets = context.getStringAttribute("resultSets");
   //(仅对 insert 有用) 标记一个属性, MyBatis 会通过 getGeneratedKeys 或者通过 insert 语句的 selectKey 子元素设置它的值
   String keyProperty = context.getStringAttribute("keyProperty");
   //(仅对 insert 有用) 标记一个属性, MyBatis 会通过 getGeneratedKeys 或者通过 insert 语句的 selectKey 子元素设置它的值
   String keyColumn = context.getStringAttribute("keyColumn");
   KeyGenerator keyGenerator;
   String keyStatementId = id + SelectKeyGenerator.SELECT_KEY_SUFFIX;
   keyStatementId = builderAssistant.applyCurrentNamespace(keyStatementId, true);
   if (configuration.hasKeyGenerator(keyStatementId)) {
     keyGenerator = configuration.getKeyGenerator(keyStatementId);
   } else {
     keyGenerator = context.getBooleanAttribute("useGeneratedKeys",
         configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType))
         ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
   }

//又去调助手类
   builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
       fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
       resultSetTypeEnum, flushCache, useCache, resultOrdered, 
       keyGenerator, keyProperty, keyColumn, databaseId, langDriver, resultSets);
 }
 
源代码25 项目: mybatis   文件: XMLStatementBuilder.java
public void parseStatementNode() {
   String id = context.getStringAttribute("id");
   String databaseId = context.getStringAttribute("databaseId");

   //如果databaseId不匹配,退出
   if (!databaseIdMatchesCurrent(id, databaseId, this.requiredDatabaseId)) {
     return;
   }

   //暗示驱动程序每次批量返回的结果行数
   Integer fetchSize = context.getIntAttribute("fetchSize");
   //超时时间
   Integer timeout = context.getIntAttribute("timeout");
   //引用外部 parameterMap,已废弃
   String parameterMap = context.getStringAttribute("parameterMap");
   //参数类型
   String parameterType = context.getStringAttribute("parameterType");
   Class<?> parameterTypeClass = resolveClass(parameterType);
   //引用外部的 resultMap(高级功能)
   String resultMap = context.getStringAttribute("resultMap");
   //结果类型
   String resultType = context.getStringAttribute("resultType");
   //脚本语言,mybatis3.2的新功能
   String lang = context.getStringAttribute("lang");
   //得到语言驱动
   LanguageDriver langDriver = getLanguageDriver(lang);

   Class<?> resultTypeClass = resolveClass(resultType);
   //结果集类型,FORWARD_ONLY|SCROLL_SENSITIVE|SCROLL_INSENSITIVE 中的一种
   String resultSetType = context.getStringAttribute("resultSetType");
   //语句类型, STATEMENT|PREPARED|CALLABLE 的一种
   StatementType statementType = StatementType.valueOf(context.getStringAttribute("statementType", StatementType.PREPARED.toString()));
   ResultSetType resultSetTypeEnum = resolveResultSetType(resultSetType);

   //获取命令类型(select|insert|update|delete)
   String nodeName = context.getNode().getNodeName();
   SqlCommandType sqlCommandType = SqlCommandType.valueOf(nodeName.toUpperCase(Locale.ENGLISH));
   boolean isSelect = sqlCommandType == SqlCommandType.SELECT;
   boolean flushCache = context.getBooleanAttribute("flushCache", !isSelect);
   //是否要缓存select结果
   boolean useCache = context.getBooleanAttribute("useCache", isSelect);
   //仅针对嵌套结果 select 语句适用:如果为 true,就是假设包含了嵌套结果集或是分组了,这样的话当返回一个主结果行的时候,就不会发生有对前面结果集的引用的情况。
   //这就使得在获取嵌套的结果集的时候不至于导致内存不够用。默认值:false。 
   boolean resultOrdered = context.getBooleanAttribute("resultOrdered", false);

   // Include Fragments before parsing
   //解析之前先解析<include>SQL片段
   XMLIncludeTransformer includeParser = new XMLIncludeTransformer(configuration, builderAssistant);
   includeParser.applyIncludes(context.getNode());

   // Parse selectKey after includes and remove them.
   //解析之前先解析<selectKey>
   processSelectKeyNodes(id, parameterTypeClass, langDriver);
   
   // Parse the SQL (pre: <selectKey> and <include> were parsed and removed)
   //解析成SqlSource,一般是DynamicSqlSource
   SqlSource sqlSource = langDriver.createSqlSource(configuration, context, parameterTypeClass);
   String resultSets = context.getStringAttribute("resultSets");
   //(仅对 insert 有用) 标记一个属性, MyBatis 会通过 getGeneratedKeys 或者通过 insert 语句的 selectKey 子元素设置它的值
   String keyProperty = context.getStringAttribute("keyProperty");
   //(仅对 insert 有用) 标记一个属性, MyBatis 会通过 getGeneratedKeys 或者通过 insert 语句的 selectKey 子元素设置它的值
   String keyColumn = context.getStringAttribute("keyColumn");
   KeyGenerator keyGenerator;
   String keyStatementId = id + SelectKeyGenerator.SELECT_KEY_SUFFIX;
   keyStatementId = builderAssistant.applyCurrentNamespace(keyStatementId, true);
   if (configuration.hasKeyGenerator(keyStatementId)) {
     keyGenerator = configuration.getKeyGenerator(keyStatementId);
   } else {
     keyGenerator = context.getBooleanAttribute("useGeneratedKeys",
         configuration.isUseGeneratedKeys() && SqlCommandType.INSERT.equals(sqlCommandType))
         ? new Jdbc3KeyGenerator() : new NoKeyGenerator();
   }

//又去调助手类
   builderAssistant.addMappedStatement(id, sqlSource, statementType, sqlCommandType,
       fetchSize, timeout, parameterMap, parameterTypeClass, resultMap, resultTypeClass,
       resultSetTypeEnum, flushCache, useCache, resultOrdered, 
       keyGenerator, keyProperty, keyColumn, databaseId, langDriver, resultSets);
 }