-
局部策略优于全局策略
查看全部 -
deleteByWrapper
查看全部 -
deleteBatchIds
查看全部 -
deleteByMap
查看全部 -
deleteById
查看全部 -
updateWrapper
查看全部 -
condition作用
查看全部 -
需求9的代码
查看全部 -
一、查询需求
1、名字中包含雨并且年龄小于40
name like '%雨%' and age<40
2、名字中包含雨年并且龄大于等于20且小于等于40并且email不为空
name like '%雨%' and age between 20 and 40 and email is not null
3、名字为王姓或者年龄大于等于25,按照年龄降序排列,年龄相同按照id升序排列
name like '王%' or age>=25 order by age desc,id asc
4、创建日期为2019年2月14日并且直属上级为名字为王姓
date_format(create_time,'%Y-%m-%d')='2019-02-14' and manager_id in (select id from user where name like '王%')
5、名字为王姓并且(年龄小于40或邮箱不为空)
name like '王%' and (age<40 or email is not null)
6、名字为王姓或者(年龄小于40并且年龄大于20并且邮箱不为空)
name like '王%' or (age<40 and age>20 and email is not null)
7、(年龄小于40或邮箱不为空)并且名字为王姓
(age<40 or email is not null) and name like '王%'
8、年龄为30、31、34、35
age in (30、31、34、35)
9、只返回满足条件的其中一条语句即可
limit 1
二、select中字段不全部出现的查询
10、名字中包含雨并且年龄小于40(需求1加强版)
第一种情况:select id,name
from user
where name like '%雨%' and age<40
第二种情况:select id,name,age,email
from user
where name like '%雨%' and age<40
三、统计查询:
11、按照直属上级分组,查询每组的平均年龄、最大年龄、最小年龄。
并且只取年龄总和小于500的组。
select avg(age) avg_age,min(age) min_age,max(age) max_age
from user
group by manager_id
having sum(age) <500
查看全部 -
MP在mybatis启动的时候,它在mybatis的xml和注解注入之后,紧接着反射分析实体,然后注入到底层容器中。就是注入crud之类的。注入之前MP会进行判断,是否已经注入同样的方法,如果注入,就不在注入。它的注入时机在容器启动时,所以MP使用crud、本身是无性能损耗的。
查看全部 -
只查询某些字段
select(可变参数)
select(传入lambda四大函数之一 predicate)
查看全部 -
排除非表字段的三种方式
1. 使用 transient 修饰
private transient String remark;
2. 使用static修饰
private static String remark;
3. @TableField(exist=false)
查看全部 -
MyBatis-Plus特性:
无侵入,损耗小、强大的CRUD操作
支持Lambda形式调用、支持多种数据库
支持主键自动生成、支持ActiveRecord模式
查看全部 -
transient关键词:该字段不参与序列化过程;
静态变量:变量会归属于类而不是对象;
@TableFieldId(exit=false):推荐用法。
查看全部 -
排除非表字段的三种方式
1. 使用 transient 修饰
private transient String remark;
2. 使用static修饰
private static String remark;
3. @TableField(exist=false)
@TableField(exist = false) private String remark;
查看全部
举报