当前位置:网站首页>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; }
创建文件:
边栏推荐
- Interesting Kotlin 0x0E: DeepRecursiveFunction
- 嵌入式系统驱动初级【3】——字符设备驱动基础中_IO模型
- Performance testing with Loadrunner
- 力扣:70. 爬楼梯
- 入坑软件测试的经验与建议
- Towards Real-Time Multi-Object Tracking (JDE)
- sql server如何得到本条记录与上一条记录的差异,即变动值
- 自动化测试的成本高效果差,那么自动化测试的意义在哪呢?
- 力扣题解8/3
- 解决错误:npm WARN config global `--global`, `--local` are deprecated
猜你喜欢
随机推荐
OpenGL绘制一个圆锥
部署LVS-DR群集【实验】
获取单选框选中内容
C1认证之web基础知识及习题——我的学习笔记
Resolved error: npm WARN config global `--global`, `--local` are deprecated
npm init [email protected] 构建项目报错SyntaxError: Unexpected token ‘.‘解决办法
How to view sql execution plan offline collection
Get the selected content of the radio box
MySQL数据库(基础)
SLSA 框架与软件供应链安全防护
C专家编程 第5章 对链接的思考 5.3 函数库链接的5个特殊秘密
el-Select 选择器 底部固定
使用Loadrunner进行性能测试
leetcode 12. 整数转罗马数字
入坑软件测试的经验与建议
flink cdc一启动,源端Oracle那台服务器的CPU就飙升到80%以上,会是啥原因呢?
腾讯136道高级岗面试题:多线程+算法+Redis+JVM
C Expert Programming Chapter 5 Thinking about Chaining 5.6 Take it easy --- see who's talking: take the Turning quiz
力扣:746. 使用最小花费爬楼梯
The difference between px, em, and rem