当前位置:网站首页>8.03 Day34---BaseMapper query statement usage
8.03 Day34---BaseMapper query statement usage
2022-08-04 05:30:00 【Which cookie are you?】
目录
BaseMapperquery statement usage:
WrapperClause constructor parent class:
用@Dataand add dependencies instead of the ones in the entity classtoString Getter和Setter方法
验证 List selectList(@Param("ew") Wrapper queryWrapper);语句:
Add the following method in the startup class,即可告诉MyBatis,我们使用的是MySql数据库:
配置web/resource目录 JSP的前缀和后缀 Tomcat端口号:
开启MyBatis的SQLStatement log print:
BaseMapperquery statement usage:
Wrapper:

双击Shift找Wrapper的源代码:

WrapperClause constructor parent class:
1.QueryWrapper<T> 作为whereConstructor for conditional clauses
2.UpdateWrapper<T> 修改setConstructor for clauses
用@Dataand add dependencies instead of the ones in the entity classtoString Getter和Setter方法

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>@Data注解:用于注解实体类




验证 List<T> selectList(@Param("ew") Wrapper<T> queryWrapper);语句:


Page类:
Add the following method in the startup class,即可告诉MyBatis,我们使用的是MySql数据库:
验证<E extends IPage<T>> E selectPage(E page, @Param("ew") Wrapper<T> queryWrapper);方法:

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
return mybatisPlusInterceptor;
}






框架整合:

创建工程:


创建web目录:


安装依赖 MySQL版本降级:

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
<scope>provided</scope>
</dependency>
配置web/resource目录 JSP的前缀和后缀 Tomcat端口号:

spring.application.name=springboot-mybatisplus-01 server.port=8084 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.name=defaultDataSource spring.datasource.url=jdbc:mysql://localhost:3306/shop?useUnicode=true&characterEncoding=utf-8&useSSL=false spring.datasource.username=root spring.datasource.password=root mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl spring.mvc.view.prefix=/jsp/ spring.mvc.view.suffix=.jsp

<resources>
<resource>
<directory>src/main/web</directory>
<targetPath>META-INF/resources</targetPath>
<includes>
<include>**/*.*</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>开启MyBatis的SQLStatement log print:

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor(){
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
return mybatisPlusInterceptor;
}创建文件:











边栏推荐
- Tactile intelligent sharing - SSD20X realizes upgrade display progress bar
- 处理List<Map<String, String>>类型
- 【流程图】
- DataTable uses Linq for grouping and summarization, and converts the Linq result set into DataTable
- SLSA 框架与软件供应链安全防护
- Use Patroni callback script to bind VIP pit
- px、em、rem的区别
- el-Select 选择器 底部固定
- day13--postman接口测试
- 震惊,99.9% 的同学没有真正理解字符串的不可变性
猜你喜欢

leetcode 12. 整数转罗马数字

sql server如何得到本条记录与上一条记录的差异,即变动值

Do you think border-radius is just rounded corners?【Various angles】

Teenage Achievement Hackers Need These Skills

Can‘t connect to MySQL server on ‘localhost3306‘ (10061) 简洁明了的解决方法

day13--postman interface test

部署LVS-DR群集【实验】

Resolved error: npm WARN config global `--global`, `--local` are deprecated

获取单选框选中内容

Programming hodgepodge (4)
随机推荐
Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
Towards Real-Time Multi-Object Tracking(JDE)
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.2 Why does my code not work
少年成就黑客,需要这些技能
leetcode 12. Integer to Roman numeral
OpenGL绘制圆
day13--postman interface test
入坑软件测试的经验与建议
9、动态SQL
腾讯136道高级岗面试题:多线程+算法+Redis+JVM
Uni-app 小程序 App 的广告变现之路:全屏视频广告
【一步到位】Jenkins的安装、部署、启动(完整教程)
某母婴小程序加密参数解密
渗透测试(PenTest)基础指南
flink cdc一启动,源端Oracle那台服务器的CPU就飙升到80%以上,会是啥原因呢?
Tactile intelligent sharing - SSD20X realizes upgrade display progress bar
CentOS7 —— yum安装mysql
Shocked, 99.9% of the students didn't really understand the immutability of strings
擎朗智能全国研发创新中心落地光谷:去年曾获2亿美元融资
canal实现mysql数据同步