Package com.skyline.energy.exception

Examples of com.skyline.energy.exception.DaoGenerateException


    if (isReturnId) {
      if (CommonUtils.isTypePrimitive(returnType)) {
        returnType = ClassUtils.primitiveToWrapper(returnType);
      }
      if (!CommonUtils.isTypeNumber(returnType)) {
        throw new DaoGenerateException("if use @ReturnId: " + returnType + " must instance of Number");
      }
    } else {
      if (CommonUtils.isTypePrimitive(returnType)) {
        returnType = ClassUtils.primitiveToWrapper(returnType);
      }
      if (CommonUtils.isTypeVoid(returnType) || Integer.class.equals(returnType)) {
        return;
      }

      throw new DaoGenerateException("if use @Update only be used on a method return void,int,Integer");

    }

  }
View Full Code Here


  }

  public static Integer getParameIndex(Map<String, Integer> paramIndexes, String paramName)
      throws DaoGenerateException {
    if (!paramIndexes.containsKey(paramName)) {
      throw new DaoGenerateException("Missing @Param(\"" + paramName + "\") in parameter of method");
    }
    Integer index = paramIndexes.get(paramName);
    return index;
  }
View Full Code Here

            && (returnType.equals(boolean.class) || returnType.equals(Boolean.class))) {
          return method;
        }
      }
    }
    throw new DaoGenerateException("Cannot find getter of property '" + prop + "' of class: " + clazz.getName());
  }
View Full Code Here

        Class<?> componentType = null;
        Integer index = null;

        if (!paramIndexes.containsKey(actualName) && !batchParamIndexes.containsKey(actualName)) {
          throw new DaoGenerateException("Missing @Param(\"" + actualName + "\") or @BatchParam(\""
              + actualName + "\") in parameter of method");
        } else if (paramIndexes.containsKey(actualName)) {
          index = paramIndexes.get(actualName);
          componentType = paramTypes[index];
        } else {
          index = batchParamIndexes.get(actualName);

          Class<?> paramType = paramTypes[index];
          if (!paramType.isArray()) {
            throw new DaoGenerateException("@BatchParam(\"" + paramName
                + "\") only can be used on an array in parameter of method");
          }
          componentType = paramTypes[index].getComponentType();
        }

        parameterIndexes[i] = index;
        String prop = paramName.substring(pos + 1);
        Method getter = findGetterByPropertyName(componentType, prop);
        getter.setAccessible(true); //no check to upgrade performance
        getters[i] = getter;

      } else { // don't need getters
        getters[i] = null;
        if (!paramIndexes.containsKey(paramName) && !batchParamIndexes.containsKey(paramName)) {
          throw new DaoGenerateException("Missing @Param(\"" + paramName + "\") or @BatchParam(\""
              + paramName + "\")  in parameter of method");
        } else if (paramIndexes.containsKey(paramName)) {
          Integer index = paramIndexes.get(paramName);
          parameterIndexes[i] = index;
        } else {
View Full Code Here

  private void configRowMapper(Method method) throws DaoGenerateException {
    MapperBy mapperBy = method.getAnnotation(MapperBy.class);
    Class<? extends RowMapper<?>> mapperType = null;
    if (mapperBy == null) {
      throw new DaoGenerateException("Missing @MapperBy on @Query");
    } else {
      mapperType = mapperBy.value();
    }
    rowMapper = (RowMapper<?>) ReflectUtils.newInstance(mapperType);

    Class<?> returnType = method.getReturnType();
    if (isUnique) {
      Class<?> expectedType = GenericUtils.getGenericTypeOfRowMapper(mapperType);
      if (!ClassUtils.isAssignable(returnType, expectedType, true)) {
        throw new DaoGenerateException("Return type is expected as '" + expectedType.getName()
            + "' with @Unique, but actually is '" + returnType.getName() + "' in method: "
            + method.toString() + ", missing @MappedBy");
      }
    } else {
      if (!CommonUtils.isTypeList(returnType)) {
        throw new DaoGenerateException(
            "Return type is expected as 'java.util.List' without @Unique, but actually is '"
                + returnType.getName() + "' in method: " + method.toString());
      }
    }
  }
View Full Code Here

          String value = param.value();
          batchParamIndexMap.put(value, index);
          batchParamIndexes = (Integer[]) ArrayUtils.add(batchParamIndexes, new Integer(index));

          if (paramTypes[index] == null || !paramTypes[index].isArray()) {
            throw new DaoGenerateException("@BatchParam can only on an array");
          }

        }
        if (GenericTable.class.equals(annotationType)) {
          GenericTable genericTable = (GenericTable) annotation;
View Full Code Here

  }

  private void checkConfig(Class<?> returnType) throws DaoGenerateException {
    isReturnCollection = CommonUtils.isTypeCollection(returnType);
    if (isReturnCollection && StringUtils.isEmpty(vkey)) {
      throw new DaoGenerateException("need vkey in @Cache if returns collection");
    }
  }
View Full Code Here

    Class<?> returnType = method.getReturnType();
    if (isReturnId && returnType != null) {
      if (CommonUtils.isTypeList(returnType)) {
        isReturnList = true;
      } else if (!CommonUtils.isTypeArray(returnType)) {
        throw new DaoGenerateException("@ReturnId must on a method return List<? extends Number> or an array");
      } else {
        returnComponentType = returnType.getComponentType();
        if (!ClassUtils.isAssignable(returnComponentType, Number.class, true)) {
          throw new DaoGenerateException(
              "@ReturnId return an array that only can be primitive or assignable to Number");
        }

        isReturnList = false;
      }
    } else {
      if (void.class.equals(returnType) || int.class.equals(returnType.getComponentType())) {
        return;
      }
      throw new DaoGenerateException("@BatchUpdate must on a method return void or int[]");
    }
  }
View Full Code Here

TOP

Related Classes of com.skyline.energy.exception.DaoGenerateException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.