parameterType和resultMap和resultType的区别

网上写的区别都不够直观,看起来真麻烦.,不讲区别光讲理论没意义的.

parameterType

前端发给后端的值,接到后指定类型,当然自己定义的实体类也可以
下面来个指定为Long类型的例子:

    <select id="checkDeptExistUser" parameterType="Long" resultType="int">
		select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
	</select>

resultType

咱们后端发给前端的值,比如说resultType=“int”,返回给前端,当然自己定义的实体类也可以.
下面来个指定为int类型的例子:

	<select id="countDictDataByType" resultType="Integer">
	    select count(1) from sys_dict_data where dict_type=#{dictType}
	</select>

返回的实体类,东西不能少,想要自定义就得用resultMap

resultMap

咱们后端发给前端的值(可自定义),自己定义的实体类有的值你不想怎么办嗯? 就用resultMap即可.
举个例子:

<?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">
<mapper namespace="com.ruoyi.system.mapper.SysConfigMapper">

    <resultMap type="SysConfig" id="SysConfigResult">
        <id property="configId" column="config_id"/>
        <result property="configName" column="config_name"/>
        <result property="configKey" column="config_key"/>
        .....
    </resultMap>

    <select id="checkConfigKeyUnique" parameterType="String" resultMap="SysConfigResult">
        select config_id from sys_config
        where config_key = #{configKey}
    </select>

和resultType区别就说可以自定义,想返回什么字段就返回什么字段

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值