当前位置: 首页>>代码示例>>Java>>正文


Java TypeHandlerRegistry.getTypeHandler方法代码示例

本文整理汇总了Java中org.apache.ibatis.type.TypeHandlerRegistry.getTypeHandler方法的典型用法代码示例。如果您正苦于以下问题:Java TypeHandlerRegistry.getTypeHandler方法的具体用法?Java TypeHandlerRegistry.getTypeHandler怎么用?Java TypeHandlerRegistry.getTypeHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.type.TypeHandlerRegistry的用法示例。


在下文中一共展示了TypeHandlerRegistry.getTypeHandler方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: registerJavaTypeInitializingTypeHandler

import org.apache.ibatis.type.TypeHandlerRegistry; //导入方法依赖的package包/类
@Test
public void registerJavaTypeInitializingTypeHandler() {
  final String MAPPER_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
      + "<!DOCTYPE configuration PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\" \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\n" 
      + "<configuration>\n" 
      + "  <typeHandlers>\n"
      + "    <typeHandler javaType=\"org.apache.ibatis.builder.XmlConfigBuilderTest$MyEnum\"\n"
      + "      handler=\"org.apache.ibatis.builder.XmlConfigBuilderTest$EnumOrderTypeHandler\"/>\n" 
      + "  </typeHandlers>\n" 
      + "</configuration>\n";

  XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
  builder.parse();

  TypeHandlerRegistry typeHandlerRegistry = builder.getConfiguration().getTypeHandlerRegistry();
  TypeHandler<MyEnum> typeHandler = typeHandlerRegistry.getTypeHandler(MyEnum.class);

  assertTrue(typeHandler instanceof EnumOrderTypeHandler);
  assertArrayEquals(MyEnum.values(), ((EnumOrderTypeHandler) typeHandler).constants);
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:21,代码来源:XmlConfigBuilderTest.java

示例2: getTypeHandlers

import org.apache.ibatis.type.TypeHandlerRegistry; //导入方法依赖的package包/类
private TypeHandler<?>[] getTypeHandlers(TypeHandlerRegistry typeHandlerRegistry, MetaObject metaParam, String[] keyProperties, ResultSetMetaData rsmd) throws SQLException {
  TypeHandler<?>[] typeHandlers = new TypeHandler<?>[keyProperties.length];
  for (int i = 0; i < keyProperties.length; i++) {
    if (metaParam.hasSetter(keyProperties[i])) {
      TypeHandler<?> th;
      try {
        Class<?> keyPropertyType = metaParam.getSetterType(keyProperties[i]);
        th = typeHandlerRegistry.getTypeHandler(keyPropertyType, JdbcType.forCode(rsmd.getColumnType(i + 1)));
      } catch (BindingException e) {
        th = null;
      }
      typeHandlers[i] = th;
    }
  }
  return typeHandlers;
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:17,代码来源:Jdbc3KeyGenerator.java

示例3: getTypeHandlers

import org.apache.ibatis.type.TypeHandlerRegistry; //导入方法依赖的package包/类
private TypeHandler<?>[] getTypeHandlers(TypeHandlerRegistry typeHandlerRegistry, MetaObject metaParam, String[] keyProperties) {
    TypeHandler<?>[] typeHandlers = new TypeHandler<?>[keyProperties.length];
    for (int i = 0; i < keyProperties.length; i++) {
        if (metaParam.hasSetter(keyProperties[i])) {
            Class<?> keyPropertyType = metaParam.getSetterType(keyProperties[i]);
            TypeHandler<?> th = typeHandlerRegistry.getTypeHandler(keyPropertyType);
            typeHandlers[i] = th;
        }
    }
    return typeHandlers;
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:12,代码来源:MultipleJdbc3KeyGenerator.java

示例4: resolveTypeHandler

import org.apache.ibatis.type.TypeHandlerRegistry; //导入方法依赖的package包/类
private void resolveTypeHandler() {
  if (resultMapping.typeHandler == null && resultMapping.javaType != null) {
    Configuration configuration = resultMapping.configuration;
    TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
    resultMapping.typeHandler = typeHandlerRegistry.getTypeHandler(resultMapping.javaType, resultMapping.jdbcType);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:8,代码来源:ResultMapping.java

示例5: resolveTypeHandler

import org.apache.ibatis.type.TypeHandlerRegistry; //导入方法依赖的package包/类
private void resolveTypeHandler() {
  if (parameterMapping.typeHandler == null && parameterMapping.javaType != null) {
    Configuration configuration = parameterMapping.configuration;
    TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
    parameterMapping.typeHandler = typeHandlerRegistry.getTypeHandler(parameterMapping.javaType, parameterMapping.jdbcType);
  }
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:8,代码来源:ParameterMapping.java

示例6: getTypeHandlers

import org.apache.ibatis.type.TypeHandlerRegistry; //导入方法依赖的package包/类
private TypeHandler<?>[] getTypeHandlers(TypeHandlerRegistry typeHandlerRegistry, MetaObject metaParam, String[] keyProperties, ResultSetMetaData rsmd) throws SQLException {
  TypeHandler<?>[] typeHandlers = new TypeHandler<?>[keyProperties.length];
  for (int i = 0; i < keyProperties.length; i++) {
    if (metaParam.hasSetter(keyProperties[i])) {
      Class<?> keyPropertyType = metaParam.getSetterType(keyProperties[i]);
      TypeHandler<?> th = typeHandlerRegistry.getTypeHandler(keyPropertyType, JdbcType.forCode(rsmd.getColumnType(i + 1)));
      typeHandlers[i] = th;
    }
  }
  return typeHandlers;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:12,代码来源:Jdbc3KeyGenerator.java

示例7: resolveTypeHandler

import org.apache.ibatis.type.TypeHandlerRegistry; //导入方法依赖的package包/类
private void resolveTypeHandler() {
    //如果没有指定特殊的typeHandler,则根据javaType,jdbcType来查表确定一个默认的typeHandler
  if (parameterMapping.typeHandler == null && parameterMapping.javaType != null) {
    Configuration configuration = parameterMapping.configuration;
    TypeHandlerRegistry typeHandlerRegistry = configuration.getTypeHandlerRegistry();
    parameterMapping.typeHandler = typeHandlerRegistry.getTypeHandler(parameterMapping.javaType, parameterMapping.jdbcType);
  }
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:9,代码来源:ParameterMapping.java

示例8: getTypeHandlers

import org.apache.ibatis.type.TypeHandlerRegistry; //导入方法依赖的package包/类
private TypeHandler<?>[] getTypeHandlers(TypeHandlerRegistry typeHandlerRegistry, MetaObject metaParam, String[] keyProperties) {
  TypeHandler<?>[] typeHandlers = new TypeHandler<?>[keyProperties.length];
  for (int i = 0; i < keyProperties.length; i++) {
    if (metaParam.hasSetter(keyProperties[i])) {
      Class<?> keyPropertyType = metaParam.getSetterType(keyProperties[i]);
      TypeHandler<?> th = typeHandlerRegistry.getTypeHandler(keyPropertyType);
      typeHandlers[i] = th;
    }
  }
  return typeHandlers;
}
 
开发者ID:shurun19851206,项目名称:mybaties,代码行数:12,代码来源:Jdbc3KeyGenerator.java


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