本文整理汇总了Java中org.apache.ibatis.type.TypeAliasRegistry类的典型用法代码示例。如果您正苦于以下问题:Java TypeAliasRegistry类的具体用法?Java TypeAliasRegistry怎么用?Java TypeAliasRegistry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TypeAliasRegistry类属于org.apache.ibatis.type包,在下文中一共展示了TypeAliasRegistry类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindAlias
import org.apache.ibatis.type.TypeAliasRegistry; //导入依赖的package包/类
void bindAlias(_MyBatis myBatis)
{
SqlSessionFactory sqlSessionFactory = mybatisConfig.mSqlSessionFactoryBuilder.getFactory();
Configuration configuration = sqlSessionFactory.getConfiguration();
TypeAliasRegistry typeAliasRegistry = configuration.getTypeAliasRegistry();
if (WPTool.notNullAndEmpty(myBatis.daoAlias))
{
typeAliasRegistry.registerAlias(myBatis.daoAlias, myBatis.daoClass);
} else if (myBatis.isAutoAlias)
{
typeAliasRegistry.registerAlias(myBatis.daoClass);
}
if (!myBatis.entityClass.equals(MyBatis.class))
{
if (WPTool.notNullAndEmpty(myBatis.entityAlias))
{
typeAliasRegistry.registerAlias(myBatis.entityAlias, myBatis.entityClass);
} else if (myBatis.isAutoAlias)
{
typeAliasRegistry.registerAlias(myBatis.entityClass);
}
}
}
示例2: handleTypeAlias
import org.apache.ibatis.type.TypeAliasRegistry; //导入依赖的package包/类
/**
* 加载别名
* @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);
}
}
}
}
}
示例3: testAddATypeAlias
import org.apache.ibatis.type.TypeAliasRegistry; //导入依赖的package包/类
@Test
public void testAddATypeAlias() throws Exception {
setupFactoryBean();
factoryBean.setTypeAliases(new Class[] { DummyTypeAlias.class });
TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry();
typeAliasRegistry.resolveAlias("testAlias");
}
示例4: testSearchATypeAliasPackage
import org.apache.ibatis.type.TypeAliasRegistry; //导入依赖的package包/类
@Test
public void testSearchATypeAliasPackage() throws Exception {
setupFactoryBean();
factoryBean.setTypeAliasesPackage("org/mybatis/spring/type");
TypeAliasRegistry typeAliasRegistry = factoryBean.getObject().getConfiguration().getTypeAliasRegistry();
typeAliasRegistry.resolveAlias("testAlias");
typeAliasRegistry.resolveAlias("testAlias2");
typeAliasRegistry.resolveAlias("dummyTypeHandler");
typeAliasRegistry.resolveAlias("superType");
}
示例5: getTypeAliasRegistry
import org.apache.ibatis.type.TypeAliasRegistry; //导入依赖的package包/类
public TypeAliasRegistry getTypeAliasRegistry() {
return typeAliasRegistry;
}
示例6: testTypeAlias
import org.apache.ibatis.type.TypeAliasRegistry; //导入依赖的package包/类
@Test
public void testTypeAlias() {
TypeAliasRegistry typeAliasRegistry = sqlSessionFactory.getConfiguration().getTypeAliasRegistry();
typeAliasRegistry.resolveAlias("testAlias");
}
示例7: getTypeAliasRegistry
import org.apache.ibatis.type.TypeAliasRegistry; //导入依赖的package包/类
public TypeAliasRegistry getTypeAliasRegistry() {
return typeAliasRegistry;
}
示例8: registerAliases
import org.apache.ibatis.type.TypeAliasRegistry; //导入依赖的package包/类
private void registerAliases(TypeAliasRegistry registry) {
registry.registerAlias("LinkedHashMap", LinkedHashMap.class);
registry.registerAlias("WqpArrayTypeHandler", WqpArrayTypeHandler.class);
registry.registerAlias("WildCardTypeHandler", WildCardTypeHandler.class);
}