org.apache.ibatis.type.TypeAliasRegistry Java Examples
The following examples show how to use
org.apache.ibatis.type.TypeAliasRegistry.
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: MapperScanApplication.java From mumu with Apache License 2.0 | 5 votes |
/** * 加载别名 * @param configuration */ private void handleTypeAlias(Configuration configuration, XNode root) { log.info("load alias message..........................."); TypeAliasRegistry typeAliasRegistry = configuration.getTypeAliasRegistry(); XNode parent = root.evalNode("typeAliases"); if(parent!=null){ for (XNode child : parent.getChildren()) { if ("package".equals(child.getName())) { String typeAliasPackage = child.getStringAttribute("name"); configuration.getTypeAliasRegistry().registerAliases(typeAliasPackage); log.info("package:"+typeAliasPackage); } else { String alias = child.getStringAttribute("alias"); String type = child.getStringAttribute("type"); try { Class<?> clazz = Resources.classForName(type); if (alias == null) { typeAliasRegistry.registerAlias(clazz); } else { typeAliasRegistry.registerAlias(alias, clazz); } log.info("alias:"+alias+" type:"+clazz); } catch (ClassNotFoundException e) { throw new BuilderException("Error registering typeAlias for '" + alias + "'. Cause: " + e, e); } } } } }
Example #2
Source File: MyBatisDataStore.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Register simple package-less aliases for all parameter and return types in the DAO. */ private void registerSimpleAliases(final Class<? extends DataAccess> accessType) { TypeAliasRegistry registry = sessionFactory.getConfiguration().getTypeAliasRegistry(); TypeLiteral<?> resolvedType = TypeLiteral.get(accessType); for (Method method : accessType.getMethods()) { for (TypeLiteral<?> parameterType : resolvedType.getParameterTypes(method)) { registerSimpleAlias(registry, parameterType.getRawType()); } registerSimpleAlias(registry, resolvedType.getReturnType(method).getRawType()); } }
Example #3
Source File: MyBatisDataStore.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
/** * Registers a simple package-less alias for the resolved type. */ private void registerSimpleAlias(final TypeAliasRegistry registry, final Class<?> clazz) { if (!clazz.isPrimitive() && !clazz.getName().startsWith("java.")) { try { registry.registerAlias(clazz); } catch (RuntimeException | LinkageError e) { debug("Unable to register type alias", e); } } }
Example #4
Source File: Configuration.java From Shop-for-JavaWeb with MIT License | 4 votes |
public TypeAliasRegistry getTypeAliasRegistry() { return typeAliasRegistry; }
Example #5
Source File: Configuration.java From mybaties with Apache License 2.0 | 4 votes |
public TypeAliasRegistry getTypeAliasRegistry() { return typeAliasRegistry; }
Example #6
Source File: AutodiscoverTest.java From mybaties with Apache License 2.0 | 4 votes |
@Test public void testTypeAlias() { TypeAliasRegistry typeAliasRegistry = sqlSessionFactory.getConfiguration().getTypeAliasRegistry(); typeAliasRegistry.resolveAlias("testAlias"); }
Example #7
Source File: Configuration.java From mybatis with Apache License 2.0 | 4 votes |
public TypeAliasRegistry getTypeAliasRegistry() { return typeAliasRegistry; }
Example #8
Source File: AutodiscoverTest.java From mybatis with Apache License 2.0 | 4 votes |
@Test public void testTypeAlias() { TypeAliasRegistry typeAliasRegistry = sqlSessionFactory.getConfiguration().getTypeAliasRegistry(); typeAliasRegistry.resolveAlias("testAlias"); }
Example #9
Source File: MybatisTypeAliasConfigurator.java From flowable-engine with Apache License 2.0 | votes |
void configure(TypeAliasRegistry typeAliasRegistry);