org.apache.ibatis.builder.BuilderException.<init>()方法的使用及代码示例

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

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

BuilderException.<init>介绍

暂无

代码示例

代码示例来源: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 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: 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);
 }
}

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

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

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

protected Class<?> resolveClass(String alias) {
 if (alias == null) {
  return null;
 }
 try {
  return resolveAlias(alias);
 } catch (Exception e) {
  throw new BuilderException("Error resolving class. Cause: " + e, e);
 }
}

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

private Map<String, String> parseParameterMapping(String content) {
  try {
   return new ParameterExpression(content);
  } catch (BuilderException ex) {
   throw ex;
  } catch (Exception ex) {
   throw new BuilderException("Parsing error was found in mapping #{" + content + "}.  Check syntax #{property|(expression), var1=value1, var2=value2, ...} ", ex);
  }
 }
}

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

protected TypeHandler<?> resolveTypeHandler(Class<?> javaType, String typeHandlerAlias) {
 if (typeHandlerAlias == null) {
  return null;
 }
 Class<?> type = resolveClass(typeHandlerAlias);
 if (type != null && !TypeHandler.class.isAssignableFrom(type)) {
  throw new BuilderException("Type " + type.getName() + " is not a valid TypeHandler because it does not implement TypeHandler interface");
 }
 @SuppressWarnings( "unchecked" ) // already verified it is a TypeHandler
 Class<? extends TypeHandler<?>> typeHandlerType = (Class<? extends TypeHandler<?>>) type;
 return resolveTypeHandler(javaType, typeHandlerType);
}

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

private void parseConfiguration(XNode root) {
  try {
    //issue #117 read properties first
    propertiesElement(root.evalNode("properties"));
    Properties settings = settingsAsProperties(root.evalNode("settings"));
    loadCustomVfs(settings);
    loadCustomLogImpl(settings);
    typeAliasesElement(root.evalNode("typeAliases"));
    pluginElement(root.evalNode("plugins"));
    objectFactoryElement(root.evalNode("objectFactory"));
    objectWrapperFactoryElement(root.evalNode("objectWrapperFactory"));
    reflectorFactoryElement(root.evalNode("reflectorFactory"));
    settingsElement(settings);
    // read it after objectFactory and objectWrapperFactory issue #631
    environmentsElement(root.evalNode("environments"));
    databaseIdProviderElement(root.evalNode("databaseIdProvider"));
    typeHandlerElement(root.evalNode("typeHandlers"));
    mapperElement(root.evalNode("mappers"));
  } catch (Exception e) {
    throw new BuilderException("Error parsing SQL Mapper Configuration. Cause: " + e, e);
  }
}

相关文章

微信公众号

最新文章

更多

BuilderException类方法