Package com.ibatis.sqlmap.engine.type

Examples of com.ibatis.sqlmap.engine.type.TypeHandler


    protected void setParameter(PreparedStatement ps, ParameterMapping mapping, Object[] parameters, int i) throws SQLException {
        Object value = parameters[i];
        // Apply Null Value
        String nullValueString = mapping.getNullValue();
        if (nullValueString != null) {
            TypeHandler handler = mapping.getTypeHandler();
            if (handler.equals(value, nullValueString)) {
                value = null;
            }
        }

        // Set Parameter
        TypeHandler typeHandler = mapping.getTypeHandler();
        if (value != null) {
            typeHandler.setParameter(ps, i + 1, value, mapping.getJdbcTypeName());
        } else if (typeHandler instanceof CustomTypeHandler) {
            // 和上面的if一样
            typeHandler.setParameter(ps, i + 1, value, mapping.getJdbcTypeName());
        } else {
            int jdbcType = mapping.getJdbcType();
            if (jdbcType != JdbcTypeRegistry.UNKNOWN_TYPE) {
                ps.setNull(i + 1, jdbcType);
            } else {
View Full Code Here


        throw new SqlMapException("Incorrect inline parameter map format (missmatched name=value pairs): " + token);
      }
    }

    if (mapping.getTypeHandler() == null) {
      TypeHandler handler;
      if (parameterClass == null) {
        handler = typeHandlerFactory.getUnkownTypeHandler();
      } else {
        handler = resolveTypeHandler(typeHandlerFactory, parameterClass, mapping.getPropertyName(), mapping.getJavaTypeName(), mapping.getJdbcTypeName());
      }
View Full Code Here

        String name = paramParser.nextToken();
        paramParser.nextToken(); //ignore ":"
        String type = paramParser.nextToken();
        mapping.setPropertyName(name);
        mapping.setJdbcTypeName(type);
        TypeHandler handler;
        if (parameterClass == null) {
          handler = typeHandlerFactory.getUnkownTypeHandler();
        } else {
          handler = resolveTypeHandler(typeHandlerFactory, parameterClass, name, null, type);
        }
        mapping.setTypeHandler(handler);
        return mapping;
      } else if (n1 >= 5) {
        String name = paramParser.nextToken();
        paramParser.nextToken(); //ignore ":"
        String type = paramParser.nextToken();
        paramParser.nextToken(); //ignore ":"
        String nullValue = paramParser.nextToken();
        while (paramParser.hasMoreTokens()) {
          nullValue = nullValue + paramParser.nextToken();
        }
        mapping.setPropertyName(name);
        mapping.setJdbcTypeName(type);
        mapping.setNullValue(nullValue);
        TypeHandler handler;
        if (parameterClass == null) {
          handler = typeHandlerFactory.getUnkownTypeHandler();
        } else {
          handler = resolveTypeHandler(typeHandlerFactory, parameterClass, name, null, type);
        }
        mapping.setTypeHandler(handler);
        return mapping;
      } else {
        throw new SqlMapException("Incorrect inline parameter map format: " + token);
      }
    } else {
      mapping.setPropertyName(token);
      TypeHandler handler;
      if (parameterClass == null) {
        handler = typeHandlerFactory.getUnkownTypeHandler();
      } else {
        handler = resolveTypeHandler(typeHandlerFactory, parameterClass, token, null, null);
      }
View Full Code Here

  private TypeHandler resolveTypeHandler(TypeHandlerFactory typeHandlerFactory, Class clazz, String propertyName, String javaType, String jdbcType) {
  try {//我加上的
  DEBUG.P(this,"resolveTypeHandler(5)");

    TypeHandler handler = null;
    if (clazz == null) {
      // Unknown
      handler = typeHandlerFactory.getUnkownTypeHandler();
    } else if (DomTypeMarker.class.isAssignableFrom(clazz)) {
      // DOM
View Full Code Here

TOP

Related Classes of com.ibatis.sqlmap.engine.type.TypeHandler

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.