package org.apache.ibatis.demo.entity;
/**
* @author zerods
*/
public class TDemoDO {
Integer id;
String name;
// ...
}
<!-- Configuration.xml -->
<typeAliases>
<package name="org.apache.ibatis.demo.entity"/>
</typeAliases>
注释:这里的TDemoDO别名默认为tDemoDO
<!-- mapper.xml -->
<resultMap id="baseMap" type="tDemoDO">
<result property="id" column="id" jdbcType="INTEGER" />
<result property="name" column="name" jdbcType="VARCHAR" />
</resultMap>
public class TDemoDO {
Integer id;
String name;
// ...
}
<!-- Configuration.xml -->
<typeAliases>
<typeAlias type="org.apache.ibatis.demo.entity.TDemoDO" alias="tDemo" />
</typeAliases>
<!-- mapper.xml -->
<resultMap id="baseMap" type="tDemo">
<result property="id" column="id" jdbcType="INTEGER" />
<result property="name" column="name" jdbcType="VARCHAR" />
</resultMap>
@Alias("tDemo")
public class TDemoDO {
Integer id;
String name;
// ...
}
<!-- Configuration.xml -->
<typeAliases>
<typeAlias type="org.apache.ibatis.demo.entity.TDemoDO" />
</typeAliases>
<!-- mapper.xml -->
<resultMap id="baseMap" type="tDemo">
<result property="id" column="id" jdbcType="INTEGER" />
<result property="name" column="name" jdbcType="VARCHAR" />
</resultMap>
@Alias("tDemo")
public class TDemoDO {
Integer id;
String name;
// ...
}
<!-- Configuration.xml -->
<typeAliases>
<package name="org.apache.ibatis.demo.entity"/>
</typeAliases>
<!-- mapper.xml -->
<resultMap id="baseMap" type="tDemo">
<result property="id" column="id" jdbcType="INTEGER" />
<result property="name" column="name" jdbcType="VARCHAR" />
</resultMap>
总结: 个人觉得使用package + Alias注解的方式最为优雅,也方便管理
原文:https://www.cnblogs.com/zerodsLearnJava/p/12939239.html