Search in sources :

Example 1 with ParameterMode

use of org.apache.ibatis.mapping.ParameterMode in project mybatis-3 by mybatis.

the class XMLMapperBuilder method parameterMapElement.

private void parameterMapElement(List<XNode> list) throws Exception {
    for (XNode parameterMapNode : list) {
        String id = parameterMapNode.getStringAttribute("id");
        String type = parameterMapNode.getStringAttribute("type");
        Class<?> parameterClass = resolveClass(type);
        List<XNode> parameterNodes = parameterMapNode.evalNodes("parameter");
        List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
        for (XNode parameterNode : parameterNodes) {
            String property = parameterNode.getStringAttribute("property");
            String javaType = parameterNode.getStringAttribute("javaType");
            String jdbcType = parameterNode.getStringAttribute("jdbcType");
            String resultMap = parameterNode.getStringAttribute("resultMap");
            String mode = parameterNode.getStringAttribute("mode");
            String typeHandler = parameterNode.getStringAttribute("typeHandler");
            Integer numericScale = parameterNode.getIntAttribute("numericScale");
            ParameterMode modeEnum = resolveParameterMode(mode);
            Class<?> javaTypeClass = resolveClass(javaType);
            JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
            @SuppressWarnings("unchecked") Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
            ParameterMapping parameterMapping = builderAssistant.buildParameterMapping(parameterClass, property, javaTypeClass, jdbcTypeEnum, resultMap, modeEnum, typeHandlerClass, numericScale);
            parameterMappings.add(parameterMapping);
        }
        builderAssistant.addParameterMap(id, parameterClass, parameterMappings);
    }
}
Also used : XNode(org.apache.ibatis.parsing.XNode) ArrayList(java.util.ArrayList) JdbcType(org.apache.ibatis.type.JdbcType) ParameterMode(org.apache.ibatis.mapping.ParameterMode) ParameterMapping(org.apache.ibatis.mapping.ParameterMapping) TypeHandler(org.apache.ibatis.type.TypeHandler)

Aggregations

ArrayList (java.util.ArrayList)1 ParameterMapping (org.apache.ibatis.mapping.ParameterMapping)1 ParameterMode (org.apache.ibatis.mapping.ParameterMode)1 XNode (org.apache.ibatis.parsing.XNode)1 JdbcType (org.apache.ibatis.type.JdbcType)1 TypeHandler (org.apache.ibatis.type.TypeHandler)1