Java Code Examples for org.apache.ibatis.annotations.SelectKey#resultType()

The following examples show how to use org.apache.ibatis.annotations.SelectKey#resultType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapperAnnotationBuilder.java    From mybaties with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 2
Source File: MapperAnnotationBuilder.java    From mybatis with Apache License 2.0 5 votes vote down vote up
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;
}