MyBatis(六):配置之类型别名优化

MyBatis(六):配置之类型别名优化

一、为什么要进行类型别名优化

首先我们来看一下前面写的UserMapper.xml配置文件:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 命名空间namespace对应Mapper接口 -->
<mapper namespace="com.jms.dao.UserMapper">
  <!-- id对应接口中的方法 -->
  <select id="getUsers" resultType="com.jms.pojo.User">
    select * from mybaties.user
  </select>
  
  <select id="getUserbyid" parameterType="int" resultType="com.jms.pojo.User">
      select * from mybaties.user where id=#{id}
  </select>
  
  <insert id="addUser" parameterType="com.jms.pojo.User">
      insert mybaties.user value(#{id},#{username},#{password})
  </insert>
  
  <update id="UpdateUser" parameterType="com.jms.pojo.User">
      update mybaties.user set username=#{username},password=#{password} where id=#{id}
  </update>
  
  <delete id="DeleteUser" parameterType="int">
      delete from mybaties.user where id=#{id}
  </delete>
</mapper>
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » MyBatis(六):配置之类型别名优化