类org.apache.ibatis.type.TypeException源码实例Demo

下面列出了怎么用org.apache.ibatis.type.TypeException的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
protected <T> Class<? extends T> resolveAlias(String alias) {
    if (alias == null) {
        return null;
    }
    Map<String, Class<?>> typeAliases = typeAliasRegistry.getTypeAliases();
    String key = alias.toLowerCase(Locale.ENGLISH);
    if (typeAliases.containsKey(key)) {
        return typeAliasRegistry.resolveAlias(alias);
    } else {
        try {
            return (Class<T>) Class.forName(alias, false, pluginClassLoader);
        } catch (ClassNotFoundException e) {
            throw new TypeException("Could not resolve type alias '" + alias + "'.  Cause: " + e, e);
        }
    }
}
 
源代码2 项目: tutorial   文件: ArrayTypeHandler.java
@Override
public void setNonNullParameter(PreparedStatement preparedStatement, int i, T t, JdbcType jdbcType) throws SQLException {
    logger.trace("setNonNullParameter(ps, i, {}, {}", t, jdbcType);
    logger.trace("<T> {}, {}, {}, getGenericInterfaces:{} getGenericSuperclass:{} ", type, type.getTypeParameters(), type.isArray(), type.getGenericInterfaces(), type.getGenericSuperclass());
    String typeName = null;
    if (t instanceof Integer[]) {
        typeName = "integer";
    } else if (t instanceof String[]) {
        typeName = "varchar";
    } else if (t instanceof Boolean[]) {
        typeName = "boolean";
    } else if (t instanceof Double[]) {
        typeName = "numeric";
    }

    if (typeName == null) {
        throw new TypeException(
                "ArrayTypeHandler parameter typeName error, your type is "
                        + t.getClass().getName());
    }

    Connection conn = preparedStatement.getConnection();
    Array array = conn.createArrayOf(typeName, (Object[]) t);
    preparedStatement.setArray(i, array);

}
 
源代码3 项目: mybaties   文件: GeneralExceptionsTest.java
@Test
public void shouldInstantiateAndThrowAllCustomExceptions() throws Exception {
  Class<?>[] exceptionTypes = {
      BindingException.class,
      CacheException.class,
      DataSourceException.class,
      ExecutorException.class,
      LogException.class,
      ParsingException.class,
      BuilderException.class,
      PluginException.class,
      ReflectionException.class,
      PersistenceException.class,
      SqlSessionException.class,
      TransactionException.class,
      TypeException.class, 
      ScriptingException.class
  };
  for (Class<?> exceptionType : exceptionTypes) {
    testExceptionConstructors(exceptionType);
  }

}
 
源代码4 项目: mybatis   文件: GeneralExceptionsTest.java
@Test
public void shouldInstantiateAndThrowAllCustomExceptions() throws Exception {
  Class<?>[] exceptionTypes = {
      BindingException.class,
      CacheException.class,
      DataSourceException.class,
      ExecutorException.class,
      LogException.class,
      ParsingException.class,
      BuilderException.class,
      PluginException.class,
      ReflectionException.class,
      PersistenceException.class,
      SqlSessionException.class,
      TransactionException.class,
      TypeException.class, 
      ScriptingException.class
  };
  for (Class<?> exceptionType : exceptionTypes) {
    testExceptionConstructors(exceptionType);
  }

}
 
源代码5 项目: das   文件: TransController.java
@Override
public <T> Class<T> resolveAlias(String string) {
    try {
        super.resolveAlias(string);
    }catch (TypeException e){
        ClassPool cp = ClassPool.getDefault();
        CtClass clz = cp.makeClass(string);
        try {
            Class result = clz.toClass();
        } catch (CannotCompileException e1) {
            e1.printStackTrace();
        }
    }
    return super.resolveAlias(string);
}