org.apache.ibatis.builder.ResultMapResolver Java Examples

The following examples show how to use org.apache.ibatis.builder.ResultMapResolver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLMapperBuilder.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
private void parsePendingResultMaps() {
	Collection<ResultMapResolver> incompleteResultMaps = configuration
			.getIncompleteResultMaps();
	synchronized (incompleteResultMaps) {
		Iterator<ResultMapResolver> iter = incompleteResultMaps.iterator();
		while (iter.hasNext()) {
			try {
				iter.next().resolve();
				iter.remove();
			} catch (IncompleteElementException e) {
				// ResultMap is still missing a resource...
			}
		}
	}
}
 
Example #2
Source File: XMLMapperBuilder.java    From mybaties with Apache License 2.0 5 votes vote down vote up
private void parsePendingResultMaps() {
  Collection<ResultMapResolver> incompleteResultMaps = configuration.getIncompleteResultMaps();
  synchronized (incompleteResultMaps) {
    Iterator<ResultMapResolver> iter = incompleteResultMaps.iterator();
    while (iter.hasNext()) {
      try {
        iter.next().resolve();
        iter.remove();
      } catch (IncompleteElementException e) {
        // ResultMap is still missing a resource...
      }
    }
  }
}
 
Example #3
Source File: XMLMapperBuilder.java    From mybatis with Apache License 2.0 5 votes vote down vote up
private void parsePendingResultMaps() {
  Collection<ResultMapResolver> incompleteResultMaps = configuration.getIncompleteResultMaps();
  synchronized (incompleteResultMaps) {
    Iterator<ResultMapResolver> iter = incompleteResultMaps.iterator();
    while (iter.hasNext()) {
      try {
        iter.next().resolve();
        iter.remove();
      } catch (IncompleteElementException e) {
        // ResultMap is still missing a resource...
      }
    }
  }
}
 
Example #4
Source File: Configuration.java    From Shop-for-JavaWeb with MIT License 4 votes vote down vote up
public Collection<ResultMapResolver> getIncompleteResultMaps() {
	return incompleteResultMaps;
}
 
Example #5
Source File: Configuration.java    From Shop-for-JavaWeb with MIT License 4 votes vote down vote up
public void addIncompleteResultMap(ResultMapResolver resultMapResolver) {
	incompleteResultMaps.add(resultMapResolver);
}
 
Example #6
Source File: XMLMapperBuilder.java    From Shop-for-JavaWeb with MIT License 4 votes vote down vote up
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 {
			ArrayList<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;
	}
}
 
Example #7
Source File: Configuration.java    From mybaties with Apache License 2.0 4 votes vote down vote up
public Collection<ResultMapResolver> getIncompleteResultMaps() {
  return incompleteResultMaps;
}
 
Example #8
Source File: Configuration.java    From mybaties with Apache License 2.0 4 votes vote down vote up
public void addIncompleteResultMap(ResultMapResolver resultMapResolver) {
  incompleteResultMaps.add(resultMapResolver);
}
 
Example #9
Source File: XMLMapperBuilder.java    From mybaties with Apache License 2.0 4 votes vote down vote up
private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> additionalResultMappings) throws Exception {
    //错误上下文
//取得标示符   ("resultMap[userResultMap]")
//    <resultMap id="userResultMap" type="User">
//      <id property="id" column="user_id" />
//      <result property="username" column="username"/>
//      <result property="password" column="password"/>
//    </resultMap>
    ErrorContext.instance().activity("processing " + resultMapNode.getValueBasedIdentifier());
    String id = resultMapNode.getStringAttribute("id",
        resultMapNode.getValueBasedIdentifier());
    //一般拿type就可以了,后面3个难道是兼容老的代码?
    String type = resultMapNode.getStringAttribute("type",
        resultMapNode.getStringAttribute("ofType",
            resultMapNode.getStringAttribute("resultType",
                resultMapNode.getStringAttribute("javaType"))));
    //高级功能,还支持继承?
//  <resultMap id="carResult" type="Car" extends="vehicleResult">
//    <result property="doorCount" column="door_count" />
//  </resultMap>
    String extend = resultMapNode.getStringAttribute("extends");
    //autoMapping
    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())) {
        //解析result map的constructor
        processConstructorElement(resultChild, typeClass, resultMappings);
      } else if ("discriminator".equals(resultChild.getName())) {
        //解析result map的discriminator
        discriminator = processDiscriminatorElement(resultChild, typeClass, resultMappings);
      } else {
        List<ResultFlag> flags = new ArrayList<ResultFlag>();
        if ("id".equals(resultChild.getName())) {
          flags.add(ResultFlag.ID);
        }
        //调5.1.1 buildResultMappingFromContext,得到ResultMapping
        resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags));
      }
    }
    //最后再调ResultMapResolver得到ResultMap
    ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend, discriminator, resultMappings, autoMapping);
    try {
      return resultMapResolver.resolve();
    } catch (IncompleteElementException  e) {
      configuration.addIncompleteResultMap(resultMapResolver);
      throw e;
    }
  }
 
Example #10
Source File: Configuration.java    From mybatis with Apache License 2.0 4 votes vote down vote up
public Collection<ResultMapResolver> getIncompleteResultMaps() {
  return incompleteResultMaps;
}
 
Example #11
Source File: Configuration.java    From mybatis with Apache License 2.0 4 votes vote down vote up
public void addIncompleteResultMap(ResultMapResolver resultMapResolver) {
  incompleteResultMaps.add(resultMapResolver);
}
 
Example #12
Source File: XMLMapperBuilder.java    From mybatis with Apache License 2.0 4 votes vote down vote up
private ResultMap resultMapElement(XNode resultMapNode, List<ResultMapping> additionalResultMappings) throws Exception {
    //错误上下文
//取得标示符   ("resultMap[userResultMap]")
//    <resultMap id="userResultMap" type="User">
//      <id property="id" column="user_id" />
//      <result property="username" column="username"/>
//      <result property="password" column="password"/>
//    </resultMap>
    ErrorContext.instance().activity("processing " + resultMapNode.getValueBasedIdentifier());
    String id = resultMapNode.getStringAttribute("id",
        resultMapNode.getValueBasedIdentifier());
    //一般拿type就可以了,后面3个难道是兼容老的代码?
    String type = resultMapNode.getStringAttribute("type",
        resultMapNode.getStringAttribute("ofType",
            resultMapNode.getStringAttribute("resultType",
                resultMapNode.getStringAttribute("javaType"))));
    //高级功能,还支持继承?
//  <resultMap id="carResult" type="Car" extends="vehicleResult">
//    <result property="doorCount" column="door_count" />
//  </resultMap>
    String extend = resultMapNode.getStringAttribute("extends");
    //autoMapping
    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())) {
        //解析result map的constructor
        processConstructorElement(resultChild, typeClass, resultMappings);
      } else if ("discriminator".equals(resultChild.getName())) {
        //解析result map的discriminator
        discriminator = processDiscriminatorElement(resultChild, typeClass, resultMappings);
      } else {
        List<ResultFlag> flags = new ArrayList<ResultFlag>();
        if ("id".equals(resultChild.getName())) {
          flags.add(ResultFlag.ID);
        }
        //调5.1.1 buildResultMappingFromContext,得到ResultMapping
        resultMappings.add(buildResultMappingFromContext(resultChild, typeClass, flags));
      }
    }
    //最后再调ResultMapResolver得到ResultMap
    ResultMapResolver resultMapResolver = new ResultMapResolver(builderAssistant, id, typeClass, extend, discriminator, resultMappings, autoMapping);
    try {
      return resultMapResolver.resolve();
    } catch (IncompleteElementException  e) {
      configuration.addIncompleteResultMap(resultMapResolver);
      throw e;
    }
  }