当前位置:网站首页>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;
}创建文件:











边栏推荐
- Do you think border-radius is just rounded corners?【Various angles】
- 一个对象引用的思考
- 震惊,99.9% 的同学没有真正理解字符串的不可变性
- Get the selected content of the radio box
- C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.1 数组并非指针
- Tactile intelligent sharing - SSD20X realizes upgrade display progress bar
- 基于gRPC编写golang简单C2远控
- 力扣:62.不同路径
- 读者让我总结一波 redis 面试题,现在肝出来了
- 去重的几种方式
猜你喜欢
随机推荐
[C language advanced] program environment and preprocessing
The 2022 PMP exam has been delayed, should we be happy or worried?
BFC、IFC、GFC、FFC概念理解、布局规则、形成方法、用处浅析
Tactile intelligent sharing - SSD20X realizes upgrade display progress bar
npm报错Beginning October 4, 2021, all connections to the npm registry - including for package installa
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.4 使声明与定义相匹配
Chapter 5 C programming expert thinking 5.4 alert Interpositioning of links
如何将 DevSecOps 引入企业?
el-Select 选择器 底部固定
px、em、rem的区别
MySQL数据库面试题总结(2022最新版)
部署LVS-DR群集【实验】
入坑软件测试的经验与建议
Use Patroni callback script to bind VIP pit
Will the 2023 PMP exam use the new version of the textbook?Reply is here!
力扣:509. 斐波那契数
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.1 数组并非指针
附加:对于“与数据表对应的实体类“,【面对MongoDB时,使用的@Id等注解】和【以前面对MySQL时,使用的@Id等注解】,是不同的;
力扣:746. 使用最小花费爬楼梯
代码重构:面向单元测试
![[Cocos 3.5.2]开启模型合批](/img/d9/9e8f71c9a26c8052b11291fe3ba7ac.png)








