Search in sources :

Example 1 with IncompleteElementException

use of org.apache.ibatis.builder.IncompleteElementException in project mybatis-3 by mybatis.

the class MapperAnnotationBuilder method parse.

public void parse() {
    String resource = type.toString();
    if (!configuration.isResourceLoaded(resource)) {
        loadXmlResource();
        configuration.addLoadedResource(resource);
        assistant.setCurrentNamespace(type.getName());
        parseCache();
        parseCacheRef();
        Method[] methods = type.getMethods();
        for (Method method : methods) {
            try {
                // issue #237
                if (!method.isBridge()) {
                    parseStatement(method);
                }
            } catch (IncompleteElementException e) {
                configuration.addIncompleteMethod(new MethodResolver(this, method));
            }
        }
    }
    parsePendingMethods();
}
Also used : Method(java.lang.reflect.Method) IncompleteElementException(org.apache.ibatis.builder.IncompleteElementException)

Example 2 with IncompleteElementException

use of org.apache.ibatis.builder.IncompleteElementException in project mybatis-3 by mybatis.

the class XMLMapperBuilder method cacheRefElement.

private void cacheRefElement(XNode context) {
    if (context != null) {
        configuration.addCacheRef(builderAssistant.getCurrentNamespace(), context.getStringAttribute("namespace"));
        CacheRefResolver cacheRefResolver = new CacheRefResolver(builderAssistant, context.getStringAttribute("namespace"));
        try {
            cacheRefResolver.resolveCacheRef();
        } catch (IncompleteElementException e) {
            configuration.addIncompleteCacheRef(cacheRefResolver);
        }
    }
}
Also used : CacheRefResolver(org.apache.ibatis.builder.CacheRefResolver) IncompleteElementException(org.apache.ibatis.builder.IncompleteElementException)

Example 3 with IncompleteElementException

use of org.apache.ibatis.builder.IncompleteElementException in project mybatis-3 by mybatis.

the class XMLIncludeTransformer method findSqlFragment.

private Node findSqlFragment(String refid, Properties variables) {
    refid = PropertyParser.parse(refid, variables);
    refid = builderAssistant.applyCurrentNamespace(refid, true);
    try {
        XNode nodeToInclude = configuration.getSqlFragments().get(refid);
        return nodeToInclude.getNode().cloneNode(true);
    } catch (IllegalArgumentException e) {
        throw new IncompleteElementException("Could not find SQL statement to include with refid '" + refid + "'", e);
    }
}
Also used : XNode(org.apache.ibatis.parsing.XNode) IncompleteElementException(org.apache.ibatis.builder.IncompleteElementException)

Example 4 with IncompleteElementException

use of org.apache.ibatis.builder.IncompleteElementException in project mybatis-3 by mybatis.

the class XMLMapperBuilder method resultMapElement.

private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> additionalResultMappings) throws Exception {
    ErrorContext.instance().activity("processing " + resultMapNode.getValueBasedIdentifier());
    String id = resultMapNode.getStringAttribute("id", resultMapNode.getValueBasedIdentifier());
    String type = resultMapNode.getStringAttribute("type", resultMapNode.getStringAttribute("ofType", resultMapNode.getStringAttribute("resultType", resultMapNode.getStringAttribute("javaType"))));
    String extend = resultMapNode.getStringAttribute("extends");
    Boolean autoMapping = resultMapNode.getBooleanAttribute("autoMapping");
    Class<?> typeClass = resolveClass(type);
    Discriminator discriminator = null;
    List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
    resultMappings.addAll(additionalResultMappings);
    List<XNode> resultChildren = resultMapNode.getChildren();
    for (XNode resultChild : resultChildren) {
        if ("constructor".equals(resultChild.getName())) {
            processConstructorElement(resultChild, typeClass, resultMappings);
        } else if ("discriminator".equals(resultChild.getName())) {
            discriminator = processDiscriminatorElement(resultChild, typeClass, resultMappings);
        } else {
            List<ResultFlag> flags = new ArrayList<ResultFlag>();
            if ("id".equals(resultChild.getName())) {
                flags.add(ResultFlag.ID);
            }
            resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags));
        }
    }
    ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend, discriminator, resultMappings, autoMapping);
    try {
        return resultMapResolver.resolve();
    } catch (IncompleteElementException e) {
        configuration.addIncompleteResultMap(resultMapResolver);
        throw e;
    }
}
Also used : XNode(org.apache.ibatis.parsing.XNode) ArrayList(java.util.ArrayList) Discriminator(org.apache.ibatis.mapping.Discriminator) IncompleteElementException(org.apache.ibatis.builder.IncompleteElementException) ResultMapping(org.apache.ibatis.mapping.ResultMapping) ArrayList(java.util.ArrayList) List(java.util.List) ResultFlag(org.apache.ibatis.mapping.ResultFlag) ResultMapResolver(org.apache.ibatis.builder.ResultMapResolver)

Aggregations

IncompleteElementException (org.apache.ibatis.builder.IncompleteElementException)4 XNode (org.apache.ibatis.parsing.XNode)2 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CacheRefResolver (org.apache.ibatis.builder.CacheRefResolver)1 ResultMapResolver (org.apache.ibatis.builder.ResultMapResolver)1 Discriminator (org.apache.ibatis.mapping.Discriminator)1 ResultFlag (org.apache.ibatis.mapping.ResultFlag)1 ResultMapping (org.apache.ibatis.mapping.ResultMapping)1