Package org.apache.ibatis.reflection

Examples of org.apache.ibatis.reflection.MetaClass


      StringTokenizer parameterMappingParts = new StringTokenizer(content, ", \n\r\t");
      String propertyWithJdbcType = parameterMappingParts.nextToken();
      String property = extractPropertyName(propertyWithJdbcType);
      String jdbcType = extractJdbcType(propertyWithJdbcType);
      Class propertyType;
      MetaClass metaClass = MetaClass.forClass(parameterType);
      if (typeHandlerRegistry.hasTypeHandler(parameterType)) {
        propertyType = parameterType;
      } else if ("CURSOR".equals(jdbcType)) {
        propertyType = java.sql.ResultSet.class;
      } else if (metaClass.hasGetter(property)) {
        propertyType = metaClass.getGetterType(property);
      } else {
        propertyType = Object.class;
      }
      ParameterMapping.Builder builder = new ParameterMapping.Builder(configuration, property, propertyType);
      if (jdbcType != null) {
View Full Code Here


  }

  private Class resolveResultJavaType(Class resultType, String property, Class javaType) {
    if (javaType == null && property != null) {
      try {
        MetaClass metaResultType = MetaClass.forClass(resultType);
        javaType = metaResultType.getSetterType(property);
      } catch (Exception e) {
        //ignore, following null check statement will deal with the situation
      }
    }
    if (javaType == null) {
View Full Code Here

  private Class resolveParameterJavaType(Class resultType, String property, Class javaType, JdbcType jdbcType) {
    if (javaType == null) {
      if (JdbcType.CURSOR.equals(jdbcType)) {
        javaType = java.sql.ResultSet.class;
      } else {
        MetaClass metaResultType = MetaClass.forClass(resultType);
        javaType = metaResultType.getGetterType(property);
      }
    }
    if (javaType == null) {
      javaType = Object.class;
    }
View Full Code Here

      }
    }
  }

  private void createRowKeyForUnmappedProperties(ResultMap resultMap, ResultSet rs, CacheKey cacheKey) throws SQLException {
    final MetaClass metaType = MetaClass.forClass(resultMap.getType());
    final List<String> mappedColumnNames = new ArrayList<String>();
    final List<String> unmappedColumnNames = new ArrayList<String>();
    loadMappedAndUnmappedColumnNames(rs, resultMap, mappedColumnNames, unmappedColumnNames);
    for (String column : unmappedColumnNames) {
      if (metaType.findProperty(column) != null) {
        String value = rs.getString(column);
        if (value != null) {
          cacheKey.update(column);
          cacheKey.update(value);
        }
View Full Code Here

  }

  private Class resolveResultJavaType(Class resultType, String property, Class javaType) {
    if (javaType == null && property != null) {
      try {
        MetaClass metaResultType = MetaClass.forClass(resultType);
        javaType = metaResultType.getSetterType(property);
      } catch (Exception e) {
        //ignore, following null check statement will deal with the situation
      }
    }
    if (javaType == null) {
View Full Code Here

    return javaType;
  }

  private Class resolveParameterJavaType(Class resultType, String property, Class javaType) {
    if (javaType == null) {
      MetaClass metaResultType = MetaClass.forClass(resultType);
      javaType = metaResultType.getGetterType(property);
    }
    if (javaType == null) {
      throw new BuilderException("Could not determine javaType for result.  Specify property or javaType attribute.");
    }
    return javaType;
View Full Code Here

    }

    if (typeHandler == null) {
      Class resultClass = resultMapBuilder.type();
      if (resultClass != null && !Map.class.isAssignableFrom(resultClass)) {
        MetaClass metaResultClass = MetaClass.forClass(resultClass);
        Class resultType = null;
        if (metaResultClass.hasGetter(propertyName)) {
          resultType = metaResultClass.getGetterType(propertyName);
        } else if (metaResultClass.hasSetter(propertyName)) {
          resultType = metaResultClass.getSetterType(propertyName);
        }
        if (resultType != null) {
          typeHandler = config.getTypeHandlerRegistry().getTypeHandler(resultType);
        }
      } else {
View Full Code Here

      typeHandler = config.getTypeHandlerRegistry().getTypeHandler(parameterMapBuilder.type());
    }
    if (typeHandler == null) {
      Class parameterClass = parameterMapBuilder.type();
      if (parameterClass != null && !Map.class.isAssignableFrom(parameterClass)) {
        MetaClass metaParamClass = MetaClass.forClass(parameterClass);
        Class paramType = null;
        if (metaParamClass.hasGetter(propertyName)) {
          paramType = metaParamClass.getGetterType(propertyName);
        } else if (metaParamClass.hasSetter(propertyName)) {
          paramType = metaParamClass.getSetterType(propertyName);
        }
        if (paramType != null) {
          typeHandler = config.getTypeHandlerRegistry().getTypeHandler(paramType);
        }
      } else {
View Full Code Here

      StringTokenizer parameterMappingParts = new StringTokenizer(content, ", \n\r\t");
      String propertyWithJdbcType = parameterMappingParts.nextToken();
      String property = extractPropertyName(propertyWithJdbcType);
      String jdbcType = extractJdbcType(propertyWithJdbcType);
      Class<?> propertyType;
      MetaClass metaClass = MetaClass.forClass(parameterType);
      if (typeHandlerRegistry.hasTypeHandler(parameterType)) {
        propertyType = parameterType;
      } else if ("CURSOR".equals(jdbcType)) {
        propertyType = java.sql.ResultSet.class;
      } else if (metaClass.hasGetter(property)) {
        propertyType = metaClass.getGetterType(property);
      } else {
        propertyType = Object.class;
      }
      ParameterMapping.Builder builder = new ParameterMapping.Builder(configuration, property, propertyType);
      if (jdbcType != null) {
View Full Code Here

  private void settingsElement(XNode context) throws Exception {
    if (context != null) {
      Properties props = context.getChildrenAsProperties();
      // Check that all settings are known to the configuration class
      MetaClass metaConfig = MetaClass.forClass(Configuration.class);
      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).");
        }
      }
      configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(stringValueOf(props.getProperty("autoMappingBehavior"), "PARTIAL")));
      configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
View Full Code Here

TOP

Related Classes of org.apache.ibatis.reflection.MetaClass

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.