Open Source, Open Future!
  menu
107 文章
ღゝ◡╹)ノ❤️

mybatis---别名

简介

对应配置文件中的typeAliases标签。当类的全限定名过长时,我们可以用一个简称指代它,这个简称可以在上下文中使用。
不区分大小写。

分类

分为两种:系统定义别名
和自定义别名。

系统定义别名

别名映射的类型
_bytebyte
_longlong
_shortshort
_intint
_integerint
_doubledouble
_floatfloat
_booleanboolean
stringString
byteByte
longLong
shortShort
intInteger
integerInteger
doubleDouble
floatFloat
booleanBoolean
dateDate
decimalBigDecimal
bigdecimalBigDecimal
objectObject
mapMap
hashmapHashMap
listList
arraylistArrayList
collectionCollection
iteratorIterator

自定义别名

方式1:

    <typeAliases>
        <typeAlias alias="user" type="mncode.entity.User"></typeAlias>
    </typeAliases>

方式2:
扫描指定包,并在类上使用注解@Alias指定别名:

    <typeAliases>
        <package name="mncode.entity"/>
    </typeAliases>
@Alias("user")
public class User {
}