Examples of BasicParameterMapping


Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

        } else {
          vars.errorCtx.setMoreInfo("Check the parameter mapping property type or name.");
          handler = resolveTypeHandler(vars.client.getDelegate().getTypeHandlerFactory(), vars.currentParameterMap.getParameterClass(), propertyName, javaType, jdbcType);
        }

        BasicParameterMapping mapping = new BasicParameterMapping();
        mapping.setPropertyName(propertyName);
        mapping.setJdbcTypeName(jdbcType);
        mapping.setTypeName(type);
        mapping.setNullValue(nullValue);
        if (mode != null && mode.length() > 0) {
          mapping.setMode(mode);
        }
        mapping.setTypeHandler(handler);
        try {
          if (javaType != null && javaType.length() > 0) {
            mapping.setJavaType(Class.forName(javaType));
          }
        } catch (ClassNotFoundException e) {
          throw new NestedRuntimeException("Error setting javaType on parameter mapping.  Cause: " + e);
        }
View Full Code Here

Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

  // Private Methods
  //

  private void retrieveOutputParameters(CallableStatement cs, ParameterMapping[] mappings, Object[] parameters) throws SQLException {
    for (int i = 0; i < mappings.length; i++) {
      BasicParameterMapping mapping = ((BasicParameterMapping) mappings[i]);
      if (mapping.isOutputAllowed()) {
        Object o = mapping.getTypeHandler().getResult(cs, i + 1);
        parameters[i] = o;
      }
    }
  }
View Full Code Here

Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

    }
  }

  private void registerOutputParameters(CallableStatement cs, ParameterMapping[] mappings) throws SQLException {
    for (int i = 0; i < mappings.length; i++) {
      BasicParameterMapping mapping = ((BasicParameterMapping) mappings[i]);
      if (mapping.isOutputAllowed()) {
        if ( null != mapping.getTypeName() && !mapping.getTypeName().equals("") ) { //@added
          cs.registerOutParameter(i + 1, mapping.getJdbcType(), mapping.getTypeName() );
        } else {
          cs.registerOutParameter(i + 1, mapping.getJdbcType());
        }
      }
    }
  }
View Full Code Here

Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

  // Private Methods
  //

  private void retrieveOutputParameters(CallableStatement cs, ParameterMapping[] mappings, Object[] parameters) throws SQLException {
    for (int i = 0; i < mappings.length; i++) {
      BasicParameterMapping mapping = ((BasicParameterMapping) mappings[i]);
      if (mapping.isOutputAllowed()) {
        Object o = mapping.getTypeHandler().getResult(cs, i + 1);
        parameters[i] = o;
      }
    }
  }
View Full Code Here

Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

    }
  }

  private void registerOutputParameters(CallableStatement cs, ParameterMapping[] mappings) throws SQLException {
    for (int i = 0; i < mappings.length; i++) {
      BasicParameterMapping mapping = ((BasicParameterMapping) mappings[i]);
      if (mapping.isOutputAllowed()) {
        if ( null != mapping.getTypeName() && !mapping.getTypeName().equals("") ) { //@added
          cs.registerOutParameter(i + 1, mapping.getJdbcType(), mapping.getTypeName() );
        } else {
          cs.registerOutParameter(i + 1, mapping.getJdbcType());
        }
      }
    }
  }
View Full Code Here

Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

    }
  }

  private void retrieveOutputParameters(RequestScope request, CallableStatement cs, ParameterMapping[] mappings, Object[] parameters, RowHandlerCallback callback) throws SQLException {
    for (int i = 0; i < mappings.length; i++) {
      BasicParameterMapping mapping = ((BasicParameterMapping) mappings[i]);
      if (mapping.isOutputAllowed()) {
        if ("java.sql.ResultSet".equalsIgnoreCase(mapping.getJavaTypeName())) {
          ResultSet rs = (ResultSet) cs.getObject(i + 1);
          ResultMap resultMap;
          if (mapping.getResultMapName() == null) {
            resultMap = request.getResultMap();
            handleOutputParameterResults(request, resultMap, rs, callback);
          } else {
            ExtendedSqlMapClient client = (ExtendedSqlMapClient) request.getSession().getSqlMapClient();
            resultMap = client.getDelegate().getResultMap(mapping.getResultMapName());
            DefaultRowHandler rowHandler = new DefaultRowHandler();
            RowHandlerCallback handlerCallback = new RowHandlerCallback(resultMap, null, rowHandler);
            handleOutputParameterResults(request, resultMap, rs, handlerCallback);
            parameters[i] = rowHandler.getList();
          }
          rs.close();
        } else {
          parameters[i] = mapping.getTypeHandler().getResult(cs, i + 1);
        }
      }
    }
  }
View Full Code Here

Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

    }
  }

  private void registerOutputParameters(CallableStatement cs, ParameterMapping[] mappings) throws SQLException {
    for (int i = 0; i < mappings.length; i++) {
      BasicParameterMapping mapping = ((BasicParameterMapping) mappings[i]);
      if (mapping.isOutputAllowed()) {
        if (null != mapping.getTypeName() && !mapping.getTypeName().equals("")) { //@added
          cs.registerOutParameter(i + 1, mapping.getJdbcType(), mapping.getTypeName());
        } else {
          if (mapping.getNumericScale() != null && (mapping.getJdbcType() == Types.NUMERIC || mapping.getJdbcType() == Types.DECIMAL))
          {
            cs.registerOutParameter(i + 1, mapping.getJdbcType(), mapping.getNumericScale().intValue());
          } else {
            cs.registerOutParameter(i + 1, mapping.getJdbcType());
          }
        }
      }
    }
  }
View Full Code Here

Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

        } else {
          vars.errorCtx.setMoreInfo("Check the parameter mapping property type or name.");
          handler = resolveTypeHandler(vars.client.getDelegate().getTypeHandlerFactory(), vars.currentParameterMap.getParameterClass(), propertyName, javaType, jdbcType);
        }

        BasicParameterMapping mapping = new BasicParameterMapping();
        mapping.setPropertyName(propertyName);
        mapping.setJdbcTypeName(jdbcType);
        mapping.setTypeName(type);
        mapping.setResultMapName( resultMap );
        mapping.setNullValue(nullValue);
        if (mode != null && mode.length() > 0) {
          mapping.setMode(mode);
        }
        mapping.setTypeHandler(handler);
        try {
          if (javaType != null && javaType.length() > 0) {
            mapping.setJavaType(Resources.classForName(javaType));
          }
        } catch (ClassNotFoundException e) {
          throw new RuntimeException("Error setting javaType on parameter mapping.  Cause: " + e);
        }
       
        if (numericScale != null) {
          try {
            Integer scale = Integer.valueOf(numericScale);
            if (scale.intValue() < 0) {
              throw new RuntimeException("Error setting numericScale on parameter mapping.  Cause: scale must be greater than or equal to zero");
            }
           
            mapping.setNumericScale(scale);
          } catch (NumberFormatException e) {
            throw new RuntimeException("Error setting numericScale on parameter mapping.  Cause: " + numericScale + " is not a valid integer");
          }
        }
View Full Code Here

Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

    }
  }

  private void retrieveOutputParameters(RequestScope request, CallableStatement cs, ParameterMapping[] mappings, Object[] parameters, RowHandlerCallback callback) throws SQLException {
    for (int i = 0; i < mappings.length; i++) {
      BasicParameterMapping mapping = ((BasicParameterMapping) mappings[i]);
      if (mapping.isOutputAllowed()) {
        if ("java.sql.ResultSet".equalsIgnoreCase(mapping.getJavaTypeName())) {
          ResultSet rs = (ResultSet) cs.getObject(i + 1);
          ResultMap resultMap;
          if (mapping.getResultMapName() == null) {
            resultMap = request.getResultMap();
            handleOutputParameterResults(request, resultMap, rs, callback);
          } else {
            ExtendedSqlMapClient client = (ExtendedSqlMapClient) request.getSession().getSqlMapClient();
            resultMap = client.getDelegate().getResultMap(mapping.getResultMapName());
            DefaultRowHandler rowHandler = new DefaultRowHandler();
            RowHandlerCallback handlerCallback = new RowHandlerCallback(resultMap, null, rowHandler);
            handleOutputParameterResults(request, resultMap, rs, handlerCallback);
            parameters[i] = rowHandler.getList();
          }
          rs.close();
        } else {
          parameters[i] = mapping.getTypeHandler().getResult(cs, i + 1);
        }
      }
    }
  }
View Full Code Here

Examples of com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMapping

    }
  }

  private void registerOutputParameters(CallableStatement cs, ParameterMapping[] mappings) throws SQLException {
    for (int i = 0; i < mappings.length; i++) {
      BasicParameterMapping mapping = ((BasicParameterMapping) mappings[i]);
      if (mapping.isOutputAllowed()) {
        if (null != mapping.getTypeName() && !mapping.getTypeName().equals("")) { //@added
          cs.registerOutParameter(i + 1, mapping.getJdbcType(), mapping.getTypeName());
        } else {
          if (mapping.getNumericScale() != null && (mapping.getJdbcType() == Types.NUMERIC || mapping.getJdbcType() == Types.DECIMAL))
          {
            cs.registerOutParameter(i + 1, mapping.getJdbcType(), mapping.getNumericScale().intValue());
          } else {
            cs.registerOutParameter(i + 1, mapping.getJdbcType());
          }
        }
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.