在sqlMapperConfig中进行设置;

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE configuration
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
<!--非自定义别名,所有javaJDK中的类都定义了别名,别名是类名不区分大小写: map 替换java.util.Map
如果是包装类,还可以使用基本数据类型:int 替换java.lang.Integer
    --> 
    <typeAliases>
      <!--自定义别名-->
      <typeAlias  alias="Person" type="com.stone.model.Person"/> 
    </typeAliases> 

    <environments default="development">
     ...
    </environments>
    <mappers>
        ...
    </mappers>
</configuration>

在personMapper.xml中可以定义sql片段

<sql id="cols">
    id,name,addr,birthday
</sql>

<select id="sel">
   select <include refid="cols" /> from person
</select>

 

相关文章:

  • 2019-11-16
  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
  • 2022-02-24
  • 2021-12-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-07
  • 2022-12-23
  • 2021-10-01
  • 2022-12-23
  • 2022-02-21
相关资源
相似解决方案