本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}