• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Discriminator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.ibatis.mapping.Discriminator的典型用法代码示例。如果您正苦于以下问题:Java Discriminator类的具体用法?Java Discriminator怎么用?Java Discriminator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Discriminator类属于org.apache.ibatis.mapping包,在下文中一共展示了Discriminator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: processDiscriminatorElement

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
private Discriminator processDiscriminatorElement(XNode context, Class<?> resultType, List<ResultMapping> resultMappings) throws Exception {
    String column = context.getStringAttribute("column");
    String javaType = context.getStringAttribute("javaType");
    String jdbcType = context.getStringAttribute("jdbcType");
    String typeHandler = context.getStringAttribute("typeHandler");
    Class<?> javaTypeClass = resolveClass(javaType);
    @SuppressWarnings("unchecked")
    Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
    JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
    Map<String, String> discriminatorMap = new HashMap<>();
    for (XNode caseChild : context.getChildren()) {
        String value = caseChild.getStringAttribute("value");
        String resultMap = caseChild.getStringAttribute("resultMap", processNestedResultMappings(caseChild, resultMappings));
        discriminatorMap.put(value, resultMap);
    }
    return builderAssistant.buildDiscriminator(resultType, column, javaTypeClass, jdbcTypeEnum, typeHandlerClass, discriminatorMap);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:18,代码来源:MybatisXMLMapperBuilder.java


示例2: applyDiscriminator

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
private Discriminator applyDiscriminator(String resultMapId, Class<?> resultType, TypeDiscriminator discriminator) {
    if (discriminator != null) {
        String column = discriminator.column();
        Class<?> javaType = discriminator.javaType() == void.class ? String.class : discriminator.javaType();
        JdbcType jdbcType = discriminator.jdbcType() == JdbcType.UNDEFINED ? null : discriminator.jdbcType();
        @SuppressWarnings("unchecked")
        Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>) (discriminator.typeHandler() == UnknownTypeHandler.class ? null
                : discriminator.typeHandler());
        Case[] cases = discriminator.cases();
        Map<String, String> discriminatorMap = new HashMap<>();
        for (Case c : cases) {
            String value = c.value();
            String caseResultMapId = resultMapId + "-" + value;
            discriminatorMap.put(value, caseResultMapId);
        }
        return assistant.buildDiscriminator(resultType, column, javaType, jdbcType, typeHandler, discriminatorMap);
    }
    return null;
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:20,代码来源:MybatisMapperAnnotationBuilder.java


示例3: applyDiscriminator

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
private Discriminator applyDiscriminator(String resultMapId, Class<?> resultType, TypeDiscriminator discriminator) {
  if (discriminator != null) {
    String column = discriminator.column();
    Class<?> javaType = discriminator.javaType() == void.class ? String.class : discriminator.javaType();
    JdbcType jdbcType = discriminator.jdbcType() == JdbcType.UNDEFINED ? null : discriminator.jdbcType();
    @SuppressWarnings("unchecked")
    Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>)
            (discriminator.typeHandler() == UnknownTypeHandler.class ? null : discriminator.typeHandler());
    Case[] cases = discriminator.cases();
    Map<String, String> discriminatorMap = new HashMap<String, String>();
    for (Case c : cases) {
      String value = c.value();
      String caseResultMapId = resultMapId + "-" + value;
      discriminatorMap.put(value, caseResultMapId);
    }
    return assistant.buildDiscriminator(resultType, column, javaType, jdbcType, typeHandler, discriminatorMap);
  }
  return null;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:20,代码来源:MapperAnnotationBuilder.java


示例4: processDiscriminatorElement

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
private Discriminator processDiscriminatorElement(XNode context, Class<?> resultType, List<ResultMapping> resultMappings) throws Exception {
  String column = context.getStringAttribute("column");
  String javaType = context.getStringAttribute("javaType");
  String jdbcType = context.getStringAttribute("jdbcType");
  String typeHandler = context.getStringAttribute("typeHandler");
  Class<?> javaTypeClass = resolveClass(javaType);
  @SuppressWarnings("unchecked")
  Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
  JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
  Map<String, String> discriminatorMap = new HashMap<String, String>();
  for (XNode caseChild : context.getChildren()) {
    String value = caseChild.getStringAttribute("value");
    String resultMap = caseChild.getStringAttribute("resultMap", processNestedResultMappings(caseChild, resultMappings));
    discriminatorMap.put(value, resultMap);
  }
  return builderAssistant.buildDiscriminator(resultType, column, javaTypeClass, jdbcTypeEnum, typeHandlerClass, discriminatorMap);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:18,代码来源:XMLMapperBuilder.java


示例5: resolveDiscriminatedResultMap

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
public ResultMap resolveDiscriminatedResultMap(ResultSet rs, ResultMap resultMap, String columnPrefix) throws SQLException {
  Set<String> pastDiscriminators = new HashSet<String>();
  Discriminator discriminator = resultMap.getDiscriminator();
  while (discriminator != null) {
    final Object value = getDiscriminatorValue(rs, discriminator, columnPrefix);
    final String discriminatedMapId = discriminator.getMapIdFor(String.valueOf(value));
    if (configuration.hasResultMap(discriminatedMapId)) {
      resultMap = configuration.getResultMap(discriminatedMapId);
      Discriminator lastDiscriminator = discriminator;
      discriminator = resultMap.getDiscriminator();
      if (discriminator == lastDiscriminator || !pastDiscriminators.add(discriminatedMapId)) {
        break;
      }
    } else {
      break;
    }
  }
  return resultMap;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:20,代码来源:DefaultResultSetHandler.java


示例6: processDiscriminatorElement

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
private Discriminator processDiscriminatorElement(XNode context,
		Class<?> resultType, List<ResultMapping> resultMappings)
		throws Exception {
	String column = context.getStringAttribute("column");
	String javaType = context.getStringAttribute("javaType");
	String jdbcType = context.getStringAttribute("jdbcType");
	String typeHandler = context.getStringAttribute("typeHandler");
	Class<?> javaTypeClass = resolveClass(javaType);
	@SuppressWarnings("unchecked")
	Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
	JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
	Map<String, String> discriminatorMap = new HashMap<String, String>();
	for (XNode caseChild : context.getChildren()) {
		String value = caseChild.getStringAttribute("value");
		String resultMap = caseChild.getStringAttribute("resultMap",
				processNestedResultMappings(caseChild, resultMappings));
		discriminatorMap.put(value, resultMap);
	}
	return builderAssistant
			.buildDiscriminator(resultType, column, javaTypeClass,
					jdbcTypeEnum, typeHandlerClass, discriminatorMap);
}
 
开发者ID:EleTeam,项目名称:Shop-for-JavaWeb,代码行数:23,代码来源:XMLMapperBuilder.java


示例7: applyDiscriminator

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
private Discriminator applyDiscriminator(String resultMapId, Class<?> resultType, TypeDiscriminator discriminator) {
  if (discriminator != null) {
    String column = discriminator.column();
    Class<?> javaType = discriminator.javaType() == void.class ? String.class : discriminator.javaType();
    JdbcType jdbcType = discriminator.jdbcType() == JdbcType.UNDEFINED ? null : discriminator.jdbcType();
    Class<? extends TypeHandler<?>> typeHandler = discriminator.typeHandler() == UnknownTypeHandler.class ? null : discriminator.typeHandler();
    Case[] cases = discriminator.cases();
    Map<String, String> discriminatorMap = new HashMap<String, String>();
    for (Case c : cases) {
      String value = c.value();
      String caseResultMapId = resultMapId + "-" + value;
      discriminatorMap.put(value, caseResultMapId);
    }
    return assistant.buildDiscriminator(resultType, column, javaType, jdbcType, typeHandler, discriminatorMap);
  }
  return null;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:18,代码来源:MapperAnnotationBuilder.java


示例8: resultMapElement

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
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<>();
    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<>();
            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;
    }
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:34,代码来源:MybatisXMLMapperBuilder.java


示例9: applyResultMap

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
private void applyResultMap(String resultMapId, Class<?> returnType, Arg[] args, Result[] results,
                            TypeDiscriminator discriminator) {
    List<ResultMapping> resultMappings = new ArrayList<>();
    applyConstructorArgs(args, returnType, resultMappings);
    applyResults(results, returnType, resultMappings);
    Discriminator disc = applyDiscriminator(resultMapId, returnType, discriminator);
    // TODO add AutoMappingBehaviour
    assistant.addResultMap(resultMapId, returnType, null, disc, resultMappings, null);
    createDiscriminatorResultMaps(resultMapId, returnType, discriminator);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:11,代码来源:MybatisMapperAnnotationBuilder.java


示例10: applyResultMap

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
private void applyResultMap(String resultMapId, Class<?> returnType, Arg[] args, Result[] results, TypeDiscriminator discriminator) {
  List<ResultMapping> resultMappings = new ArrayList<ResultMapping>();
  applyConstructorArgs(args, returnType, resultMappings);
  applyResults(results, returnType, resultMappings);
  Discriminator disc = applyDiscriminator(resultMapId, returnType, discriminator);
  // TODO add AutoMappingBehaviour
  assistant.addResultMap(resultMapId, returnType, null, disc, resultMappings, null);
  createDiscriminatorResultMaps(resultMapId, returnType, discriminator);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:10,代码来源:MapperAnnotationBuilder.java


示例11: ResultMapResolver

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
public ResultMapResolver(MapperBuilderAssistant assistant, String id, Class<?> type, String extend, Discriminator discriminator, List<ResultMapping> resultMappings, Boolean autoMapping) {
  this.assistant = assistant;
  this.id = id;
  this.type = type;
  this.extend = extend;
  this.discriminator = discriminator;
  this.resultMappings = resultMappings;
  this.autoMapping = autoMapping;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:10,代码来源:ResultMapResolver.java


示例12: buildDiscriminator

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
public Discriminator buildDiscriminator(
    Class<?> resultType,
    String column,
    Class<?> javaType,
    JdbcType jdbcType,
    Class<? extends TypeHandler<?>> typeHandler,
    Map<String, String> discriminatorMap) {
  ResultMapping resultMapping = buildResultMapping(
      resultType,
      null,
      column,
      javaType,
      jdbcType,
      null,
      null,
      null,
      null,
      typeHandler,
      new ArrayList<ResultFlag>(),
      null,
      null,
      false);
  Map<String, String> namespaceDiscriminatorMap = new HashMap<String, String>();
  for (Map.Entry<String, String> e : discriminatorMap.entrySet()) {
    String resultMap = e.getValue();
    resultMap = applyCurrentNamespace(resultMap, true);
    namespaceDiscriminatorMap.put(e.getKey(), resultMap);
  }
  return new Discriminator.Builder(configuration, resultMapping, namespaceDiscriminatorMap).build();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:31,代码来源:MapperBuilderAssistant.java


示例13: resultMapElement

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
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;
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:37,代码来源:XMLMapperBuilder.java


示例14: prepareSelectDiscriminatedPost

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
public static MappedStatement prepareSelectDiscriminatedPost(final Configuration config) {
  final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
  final ResultMap discriminatorResultMap = new ResultMap.Builder(config, "postResultMap", HashMap.class, new ArrayList<ResultMapping>() {
    {
      add(new ResultMapping.Builder(config, "subject", "subject", registry.getTypeHandler(String.class)).build());
      add(new ResultMapping.Builder(config, "body", "body", registry.getTypeHandler(String.class)).build());
    }
  }).build();
  config.addResultMap(discriminatorResultMap);
  MappedStatement ms = new MappedStatement.Builder(config, "selectPosts", new StaticSqlSource(config,"SELECT * FROM post"), SqlCommandType.SELECT)
      .resultMaps(new ArrayList<ResultMap>() {
        {
          add(new ResultMap.Builder(config, "defaultResultMap", HashMap.class, new ArrayList<ResultMapping>() {
            {
              add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class)).build());
              add(new ResultMapping.Builder(config, "blog_id", "blog_id", registry.getTypeHandler(int.class)).build());
            }
          })
              .discriminator(new Discriminator.Builder(
                  config, new ResultMapping.Builder(config, "section", "section", registry.getTypeHandler(String.class)).build(),
                  new HashMap<String, String>() {
                    {
                      put("NEWS", discriminatorResultMap.getId());
                      put("VIDEOS", discriminatorResultMap.getId());
                      put("PODCASTS", discriminatorResultMap.getId());
                      //NEWS left out on purpose.
                    }
                  }).build()).build());

        }
      }).build();
  return ms;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:34,代码来源:ExecutorTestHelper.java


示例15: buildDiscriminator

import org.apache.ibatis.mapping.Discriminator; //导入依赖的package包/类
public Discriminator buildDiscriminator(
    Class<?> resultType,
    String column,
    Class<?> javaType,
    JdbcType jdbcType,
    Class<? extends TypeHandler<?>> typeHandler,
    Map<String, String> discriminatorMap) {
  ResultMapping resultMapping = buildResultMapping(
      resultType,
      null,
      column,
      javaType,
      jdbcType,
      null,
      null,
      null,
      null,
      typeHandler,
      new ArrayList<ResultFlag>(),
      null,
      null,
      false);
  Map<String, String> namespaceDiscriminatorMap = new HashMap<String, String>();
  for (Map.Entry<String, String> e : discriminatorMap.entrySet()) {
    String resultMap = e.getValue();
    resultMap = applyCurrentNamespace(resultMap, true);
    namespaceDiscriminatorMap.put(e.getKey(), resultMap);
  }
  Discriminator.Builder discriminatorBuilder = new Discriminator.Builder(configuration, resultMapping, namespaceDiscriminatorMap);
  return discriminatorBuilder.build();
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:32,代码来源:MapperBuilderAssistant.java



注:本文中的org.apache.ibatis.mapping.Discriminator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WindowAndroid类代码示例发布时间:2022-05-22
下一篇:
Java WebAppProxy类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap