org.apache.ibatis.builder.BuilderException类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中org.apache.ibatis.builder.BuilderException类的一些代码示例,展示了BuilderException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BuilderException类的具体详情如下:
包路径:org.apache.ibatis.builder.BuilderException
类名称:BuilderException

BuilderException介绍

暂无

代码示例

代码示例来源:origin: baomidou/mybatis-plus

private boolean isSpecifiedEnvironment(String id) {
    if (environment == null) {
      throw new BuilderException("No environment specified.");
    } else if (id == null) {
      throw new BuilderException("Environment requires an id attribute.");
    } else {
      return environment.equals(id);
    }
  }
}

代码示例来源:origin: baomidou/mybatis-plus

public Configuration parse() {
  if (parsed) {
    throw new BuilderException("Each XMLConfigBuilder can only be used once.");
  }
  parsed = true;
  parseConfiguration(parser.evalNode("/configuration"));
  return configuration;
}

代码示例来源:origin: baomidou/mybatis-plus

private Properties settingsAsProperties(XNode context) {
  if (context == null) {
    return new Properties();
  }
  Properties props = context.getChildrenAsProperties();
  // Check that all settings are known to the configuration class
  MetaClass metaConfig = MetaClass.forClass(Configuration.class, localReflectorFactory);
  for (Object key : props.keySet()) {
    if (!metaConfig.hasSetter(String.valueOf(key))) {
      throw new BuilderException("The setting " + key + " is not known.  Make sure you spelled it correctly (case sensitive).");
    }
  }
  return props;
}

代码示例来源:origin: baomidou/mybatis-plus

private void parseCacheRef() {
  CacheNamespaceRef cacheDomainRef = type.getAnnotation(CacheNamespaceRef.class);
  if (cacheDomainRef != null) {
    Class<?> refType = cacheDomainRef.value();
    String refName = cacheDomainRef.name();
    if (refType == void.class && refName.isEmpty()) {
      throw new BuilderException("Should be specified either value() or name() attribute in the @CacheNamespaceRef");
    }
    if (refType != void.class && !refName.isEmpty()) {
      throw new BuilderException("Cannot use both value() and name() attribute in the @CacheNamespaceRef");
    }
    String namespace = (refType != void.class) ? refType.getName() : refName;
    try {
      assistant.useCacheRef(namespace);
    } catch (IncompleteElementException e) {
      configuration.addIncompleteCacheRef(new CacheRefResolver(assistant, namespace));
    }
  }
}

代码示例来源:origin: baomidou/mybatis-plus

private DataSourceFactory dataSourceElement(XNode context) throws Exception {
  if (context != null) {
    String type = context.getStringAttribute("type");
    Properties props = context.getChildrenAsProperties();
    DataSourceFactory factory = (DataSourceFactory) resolveClass(type).newInstance();
    factory.setProperties(props);
    return factory;
  }
  throw new BuilderException("Environment declaration requires a DataSourceFactory.");
}

代码示例来源:origin: baomidou/mybatis-plus

private SqlSource getSqlSourceFromAnnotations(Method method, Class<?> parameterType, LanguageDriver languageDriver) {
  try {
    Class<? extends Annotation> sqlAnnotationType = getSqlAnnotationType(method);
    Class<? extends Annotation> sqlProviderAnnotationType = getSqlProviderAnnotationType(method);
    if (sqlAnnotationType != null) {
      if (sqlProviderAnnotationType != null) {
        throw new BindingException("You cannot supply both a static SQL and SqlProvider to method named " + method.getName());
      }
      Annotation sqlAnnotation = method.getAnnotation(sqlAnnotationType);
      final String[] strings = (String[]) sqlAnnotation.getClass().getMethod("value").invoke(sqlAnnotation);
      return buildSqlSourceFromStrings(strings, parameterType, languageDriver);
    } else if (sqlProviderAnnotationType != null) {
      Annotation sqlProviderAnnotation = method.getAnnotation(sqlProviderAnnotationType);
      return new ProviderSqlSource(assistant.getConfiguration(), sqlProviderAnnotation, type, method);
    }
    return null;
  } catch (Exception e) {
    throw new BuilderException("Could not find value method on SQL annotation.  Cause: " + e, e);
  }
}

代码示例来源:origin: baomidou/mybatis-plus

private TransactionFactory transactionManagerElement(XNode context) throws Exception {
  if (context != null) {
    String type = context.getStringAttribute("type");
    Properties props = context.getChildrenAsProperties();
    TransactionFactory factory = (TransactionFactory) resolveClass(type).newInstance();
    factory.setProperties(props);
    return factory;
  }
  throw new BuilderException("Environment declaration requires a TransactionFactory.");
}

代码示例来源:origin: baomidou/mybatis-plus

private boolean hasNestedSelect(Result result) {
  if (result.one().select().length() > 0 && result.many().select().length() > 0) {
    throw new BuilderException("Cannot use both @One and @Many annotations in the same @Result");
  }
  return result.one().select().length() > 0 || result.many().select().length() > 0;
}

代码示例来源:origin: baomidou/mybatis-plus

private void propertiesElement(XNode context) throws Exception {
  if (context != null) {
    Properties defaults = context.getChildrenAsProperties();
    String resource = context.getStringAttribute("resource");
    String url = context.getStringAttribute("url");
    if (resource != null && url != null) {
      throw new BuilderException("The properties element cannot specify both a URL and a resource based property file reference.  Please specify one or the other.");
    }
    if (resource != null) {
      defaults.putAll(Resources.getResourceAsProperties(resource));
    } else if (url != null) {
      defaults.putAll(Resources.getUrlAsProperties(url));
    }
    Properties vars = configuration.getVariables();
    if (vars != null) {
      defaults.putAll(vars);
    }
    parser.setVariables(defaults);
    configuration.setVariables(defaults);
  }
}

代码示例来源:origin: baomidou/mybatis-plus

mapper.add(mapperInterface);
} else {
  throw new BuilderException(
    "A mapper element may only specify a url, resource or class, but not more than one.");

代码示例来源:origin: baomidou/mybatis-plus

private void typeAliasesElement(XNode parent) {
  if (parent != null) {
    for (XNode child : parent.getChildren()) {
      if ("package".equals(child.getName())) {
        String typeAliasPackage = child.getStringAttribute("name");
        configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage);
      } else {
        String alias = child.getStringAttribute("alias");
        String type = child.getStringAttribute("type");
        try {
          Class<?> clazz = Resources.classForName(type);
          if (alias == null) {
            typeAliasRegistry.registerAlias(clazz);
          } else {
            typeAliasRegistry.registerAlias(alias, clazz);
          }
        } catch (ClassNotFoundException e) {
          throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e);
        }
      }
    }
  }
}

代码示例来源:origin: org.mybatis/mybatis

public void setCurrentNamespace(String currentNamespace) {
 if (currentNamespace == null) {
  throw new BuilderException("The mapper element requires a namespace attribute to be specified.");
 }
 if (this.currentNamespace != null && !this.currentNamespace.equals(currentNamespace)) {
  throw new BuilderException("Wrong namespace. Expected '"
    + this.currentNamespace + "' but found '" + currentNamespace + "'.");
 }
 this.currentNamespace = currentNamespace;
}

代码示例来源:origin: camunda/camunda-bpm-platform

private boolean isSpecifiedEnvironment(String id) {
 if (environment == null) {
  throw new BuilderException("No environment specified.");
 } else if (id == null) {
  throw new BuilderException("Environment requires an id attribute.");
 } else if (environment.equals(id)) {
  return true;
 }
 return false;
}

代码示例来源:origin: org.mybatis/mybatis

private boolean isSpecifiedEnvironment(String id) {
 if (environment == null) {
  throw new BuilderException("No environment specified.");
 } else if (id == null) {
  throw new BuilderException("Environment requires an id attribute.");
 } else if (environment.equals(id)) {
  return true;
 }
 return false;
}

代码示例来源:origin: camunda/camunda-bpm-platform

public void setCurrentNamespace(String currentNamespace) {
 if (currentNamespace == null) {
  throw new BuilderException("The mapper element requires a namespace attribute to be specified.");
 }
 if (this.currentNamespace != null && !this.currentNamespace.equals(currentNamespace)) {
  throw new BuilderException("Wrong namespace. Expected '"
    + this.currentNamespace + "' but found '" + currentNamespace + "'.");
 }
 this.currentNamespace = currentNamespace;
}

代码示例来源:origin: camunda/camunda-bpm-platform

private Object evaluate(String expression, Object root, QName returnType) {
 try {
  return xpath.evaluate(expression, root, returnType);
 } catch (Exception e) {
  throw new BuilderException("Error evaluating XPath.  Cause: " + e, e);
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void checkIsNotDynamic(SqlSource source) {
 if (!RawSqlSource.class.equals(source.getClass())) {
  throw new BuilderException("Dynamic content is not allowed when using RAW language");
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

private SqlNode getDefaultSqlNode(List<SqlNode> defaultSqlNodes) {
  SqlNode defaultSqlNode = null;
  if (defaultSqlNodes.size() == 1) {
   defaultSqlNode = defaultSqlNodes.get(0);
  } else if (defaultSqlNodes.size() > 1) {
   throw new BuilderException("Too many default (otherwise) elements in choose statement.");
  }
  return defaultSqlNode;
 }
}

代码示例来源:origin: org.mybatis/mybatis

private SqlNode getDefaultSqlNode(List<SqlNode> defaultSqlNodes) {
  SqlNode defaultSqlNode = null;
  if (defaultSqlNodes.size() == 1) {
   defaultSqlNode = defaultSqlNodes.get(0);
  } else if (defaultSqlNodes.size() > 1) {
   throw new BuilderException("Too many default (otherwise) elements in choose statement.");
  }
  return defaultSqlNode;
 }
}

代码示例来源:origin: camunda/camunda-bpm-platform

protected JdbcType resolveJdbcType(String alias) {
 if (alias == null) {
  return null;
 }
 try {
  return JdbcType.valueOf(alias);
 } catch (IllegalArgumentException e) {
  throw new BuilderException("Error resolving JdbcType. Cause: " + e, e);
 }
}

相关文章

微信公众号

最新文章

更多

BuilderException类方法