mybatis——mapper文件详解

用来描述select语句返回字段与java属性的映射关系。

可以有多个resultMap标签,用不同id区分不同标签。

可以实现一对多,多对多关系

–>

/* where 可以自动去除sql语句where关键字后的and关键字*/

/*

向sql传递数组或List, mybatis使用foreach解析,可以做批量处理。

collection:传入的集合的变量名称(要遍历的值)。

item:每次循环将循环出的数据放入这个变量中。

open:循环开始拼接的字符串。

close:循环结束拼接的字符串。

separator:循环中拼接的分隔符。

*/

/*

判断语句,test值等于true执行等于false跳过

test可以是一个值为Boolean型的计算语句

*/

/*

前缀’and’ 被’(’ 替换

prefix:前缀覆盖并增加其内容 不写的话默认替换为空

suffix:后缀覆盖并增加其内容 不写的话默认替换为空

prefixOverrides:前缀判断的条件

suffixOverrides:后缀判断的条件

*/

/*

choose 是或(or)的关系。

choose标签是按顺序判断其内部when标签中的test条件出否成立,如果有一个成立,则 choose 结束。

当 choose 中所有 when 的条件都不满则时,则执行 otherwise 中的sql。

类似于Java 的 switch 语句,choose 为 switch,when 为 case,otherwise 则为 default。

*/

and ${criterion.condition}

and ${criterion.condition} #{criterion.value}

and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}

and ${criterion.condition}

#{listItem}

and ${criterion.condition}

and ${criterion.condition} #{criterion.value}

and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}

and ${criterion.condition}

#{listItem}

id, name, logo, describe, is_enable, phone, admin, password, uuid

${fields}

select

distinct

/引入一个SQL模块/

from customer

order by ${orderByClause}

limit #{startRow} , #{pageSize}

select

id,name,logo,describe,is_enable,phone,admin,password,uuid

from customer

where id = #{id,jdbcType=INTEGER}

delete from customer

where id = #{id,jdbcType=INTEGER}

delete from customer

insert into customer (id, name, logo,

describe, is_enable, phone,

admin, password, uuid

)

values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{logo,jdbcType=VARCHAR},

#{describe,jdbcType=VARCHAR}, #{isEnable,jdbcType=BIT}, #{phone,jdbcType=VARCHAR},

#{admin,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{uuid,jdbcType=VARCHAR}

)

insert into customer

id,

name,

logo,

describe,

is_enable,

phone,

admin,

password,

uuid,

#{id,jdbcType=INTEGER},

#{name,jdbcType=VARCHAR},

#{logo,jdbcType=VARCHAR},

#{describe,jdbcType=VARCHAR},

#{isEnable,jdbcType=BIT},

#{phone,jdbcType=VARCHAR},

#{admin,jdbcType=VARCHAR},

#{password,jdbcType=VARCHAR},

#{uuid,jdbcType=VARCHAR},

select count(*) from customer

update customer

id = #{record.id,jdbcType=INTEGER},

name = #{record.name,jdbcType=VARCHAR},

logo = #{record.logo,jdbcType=VARCHAR},

describe = #{record.describe,jdbcType=VARCHAR},

is_enable = #{record.isEnable,jdbcType=BIT},

phone = #{record.phone,jdbcType=VARCHAR},

admin = #{record.admin,jdbcType=VARCHAR},

password = #{record.password,jdbcType=VARCHAR},

uuid = #{record.uuid,jdbcType=VARCHAR},

update customer

set id = #{record.id,jdbcType=INTEGER},

name = #{record.name,jdbcType=VARCHAR},

logo = #{record.logo,jdbcType=VARCHAR},

describe = #{record.describe,jdbcType=VARCHAR},

is_enable = #{record.isEnable,jdbcType=BIT},

phone = #{record.phone,jdbcType=VARCHAR},

admin = #{record.admin,jdbcType=VARCHAR},

password = #{record.password,jdbcType=VARCHAR},

uuid = #{record.uuid,jdbcType=VARCHAR}

update customer

name = #{name,jdbcType=VARCHAR},

logo = #{logo,jdbcType=VARCHAR},

describe = #{describe,jdbcType=VARCHAR},

is_enable = #{isEnable,jdbcType=BIT},

phone = #{phone,jdbcType=VARCHAR},

admin = #{admin,jdbcType=VARCHAR},

password = #{password,jdbcType=VARCHAR},

uuid = #{uuid,jdbcType=VARCHAR},

where id = #{id,jdbcType=INTEGER}

update customer

set name = #{name,jdbcType=VARCHAR},

logo = #{logo,jdbcType=VARCHAR},

describe = #{describe,jdbcType=VARCHAR},

is_enable = #{isEnable,jdbcType=BIT},

phone = #{phone,jdbcType=VARCHAR},

admin = #{admin,jdbcType=VARCHAR},

password = #{password,jdbcType=VARCHAR},

uuid = #{uuid,jdbcType=VARCHAR}

where id = #{id,jdbcType=INTEGER}

update customer

when #{item.id,jdbcType=INTEGER} then #{item.id,jdbcType=INTEGER}

when #{item.id,jdbcType=INTEGER} then customer.id

when #{item.id,jdbcType=INTEGER} then #{item.name,jdbcType=VARCHAR}

when #{item.id,jdbcType=INTEGER} then customer.name

when #{item.id,jdbcType=INTEGER} then #{item.logo,jdbcType=VARCHAR}

when #{item.id,jdbcType=INTEGER} then customer.logo

when #{item.id,jdbcType=INTEGER} then #{item.describe,jdbcType=VARCHAR}

when #{item.id,jdbcType=INTEGER} then customer.describe

when #{item.id,jdbcType=INTEGER} then #{item.isEnable,jdbcType=BIT}

when #{item.id,jdbcType=INTEGER} then customer.is_enable

when #{item.id,jdbcType=INTEGER} then #{item.phone,jdbcType=VARCHAR}

when #{item.id,jdbcType=INTEGER} then customer.phone

when #{item.id,jdbcType=INTEGER} then #{item.admin,jdbcType=VARCHAR}

when #{item.id,jdbcType=INTEGER} then customer.admin

when #{item.id,jdbcType=INTEGER} then #{item.password,jdbcType=VARCHAR}

when #{item.id,jdbcType=INTEGER} then customer.password

when #{item.id,jdbcType=INTEGER} then #{item.uuid,jdbcType=VARCHAR}

when #{item.id,jdbcType=INTEGER} then customer.uuid

where id in(

#{item.id,jdbcType=INTEGER}

)

insert into customer (id,

name, logo, describe,

is_enable, phone, admin,

password, uuid)

values (#{item.id,jdbcType=INTEGER},

#{item.name,jdbcType=VARCHAR}, #{item.logo,jdbcType=VARCHAR}, #{item.describe,jdbcType=VARCHAR},

#{item.isEnable,jdbcType=BIT}, #{item.phone,jdbcType=VARCHAR}, #{item.admin,jdbcType=VARCHAR},

#{item.password,jdbcType=VARCHAR}, #{item.uuid,jdbcType=VARCHAR})

delete from customer where id in (

#{id}

)

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)

img

最后

面试是跳槽涨薪最直接有效的方式,马上金九银十来了,各位做好面试造飞机,工作拧螺丝的准备了吗?

掌握了这些知识点,面试时在候选人中又可以夺目不少,暴击9999点。机会都是留给有准备的人,只有充足的准备,才可能让自己可以在候选人中脱颖而出。

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!
,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**

因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。[外链图片转存中…(img-cgYvBhs3-1713476707600)]

[外链图片转存中…(img-Gk12LIuE-1713476707603)]

[外链图片转存中…(img-ohxHe9fd-1713476707604)]

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注Java获取)

img

最后

面试是跳槽涨薪最直接有效的方式,马上金九银十来了,各位做好面试造飞机,工作拧螺丝的准备了吗?

掌握了这些知识点,面试时在候选人中又可以夺目不少,暴击9999点。机会都是留给有准备的人,只有充足的准备,才可能让自己可以在候选人中脱颖而出。

[外链图片转存中…(img-vDVwVEz9-1713476707604)]

[外链图片转存中…(img-1mNSKiBm-1713476707605)]

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值