Java Code Examples for org.apache.ibatis.mapping.SqlCommandType#UNKNOWN

The following examples show how to use org.apache.ibatis.mapping.SqlCommandType#UNKNOWN . 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: MapperMethod.java    From mybaties with Apache License 2.0 6 votes vote down vote up
public SqlCommand(Configuration configuration, Class<?> mapperInterface, Method method) {
  String statementName = mapperInterface.getName() + "." + method.getName();
  MappedStatement ms = null;
  if (configuration.hasStatement(statementName)) {
    ms = configuration.getMappedStatement(statementName);
  } else if (!mapperInterface.equals(method.getDeclaringClass().getName())) { // issue #35
    //如果不是这个mapper接口的方法,再去查父类
    String parentStatementName = method.getDeclaringClass().getName() + "." + method.getName();
    if (configuration.hasStatement(parentStatementName)) {
      ms = configuration.getMappedStatement(parentStatementName);
    }
  }
  if (ms == null) {
    throw new BindingException("Invalid bound statement (not found): " + statementName);
  }
  name = ms.getId();
  type = ms.getSqlCommandType();
  if (type == SqlCommandType.UNKNOWN) {
    throw new BindingException("Unknown execution method for: " + name);
  }
}
 
Example 2
Source File: MapperAnnotationBuilder.java    From mybaties with Apache License 2.0 6 votes vote down vote up
private SqlCommandType getSqlCommandType(Method method) {
  Class<? extends Annotation> type = getSqlAnnotationType(method);

  if (type == null) {
    type = getSqlProviderAnnotationType(method);

    if (type == null) {
      return SqlCommandType.UNKNOWN;
    }

    if (type == SelectProvider.class) {
      type = Select.class;
    } else if (type == InsertProvider.class) {
      type = Insert.class;
    } else if (type == UpdateProvider.class) {
      type = Update.class;
    } else if (type == DeleteProvider.class) {
      type = Delete.class;
    }
  }

  return SqlCommandType.valueOf(type.getSimpleName().toUpperCase(Locale.ENGLISH));
}
 
Example 3
Source File: MapperMethod.java    From mybatis with Apache License 2.0 6 votes vote down vote up
public SqlCommand(Configuration configuration, Class<?> mapperInterface, Method method) {
  String statementName = mapperInterface.getName() + "." + method.getName();
  MappedStatement ms = null;
  if (configuration.hasStatement(statementName)) {
    ms = configuration.getMappedStatement(statementName);
  } else if (!mapperInterface.equals(method.getDeclaringClass().getName())) { // issue #35
    //如果不是这个mapper接口的方法,再去查父类
    String parentStatementName = method.getDeclaringClass().getName() + "." + method.getName();
    if (configuration.hasStatement(parentStatementName)) {
      ms = configuration.getMappedStatement(parentStatementName);
    }
  }
  if (ms == null) {
    throw new BindingException("Invalid bound statement (not found): " + statementName);
  }
  name = ms.getId();
  type = ms.getSqlCommandType();
  if (type == SqlCommandType.UNKNOWN) {
    throw new BindingException("Unknown execution method for: " + name);
  }
}
 
Example 4
Source File: MapperAnnotationBuilder.java    From mybatis with Apache License 2.0 6 votes vote down vote up
private SqlCommandType getSqlCommandType(Method method) {
  Class<? extends Annotation> type = getSqlAnnotationType(method);

  if (type == null) {
    type = getSqlProviderAnnotationType(method);

    if (type == null) {
      return SqlCommandType.UNKNOWN;
    }

    if (type == SelectProvider.class) {
      type = Select.class;
    } else if (type == InsertProvider.class) {
      type = Insert.class;
    } else if (type == UpdateProvider.class) {
      type = Update.class;
    } else if (type == DeleteProvider.class) {
      type = Delete.class;
    }
  }

  return SqlCommandType.valueOf(type.getSimpleName().toUpperCase(Locale.ENGLISH));
}