当前位置:网站首页>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; }
创建文件:
边栏推荐
- [Cocos] cc.sys.browserType可能的属性
- 4.3 基于注解的声明式事务和基于XML的声明式事务
- npm报错Beginning October 4, 2021, all connections to the npm registry - including for package installa
- 力扣:96.不同的二叉搜索树
- QT 如何识别文件的编码格式
- OpenGL绘制圆
- How to view sql execution plan offline collection
- [SemiDrive source code analysis] [MailBox inter-core communication] 47 - Analysis of RPMSG_IPCC_RPC mode limit size of single transmission and limit bandwidth test
- 使用Patroni回调脚本绑定VIP的坑
- sql server如何得到本条记录与上一条记录的差异,即变动值
猜你喜欢
随机推荐
The 2022 PMP exam has been delayed, should we be happy or worried?
力扣:96.不同的二叉搜索树
附加:对于“与数据表对应的实体类“,【面对MongoDB时,使用的@Id等注解】和【以前面对MySQL时,使用的@Id等注解】,是不同的;
嵌入式系统驱动初级【4】——字符设备驱动基础下_并发控制
[Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
某母婴小程序加密参数解密
3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
9、动态SQL
Towards Real-Time Multi-Object Tracking(JDE)
[Cocos] cc.sys.browserType可能的属性
读者让我总结一波 redis 面试题,现在肝出来了
信息学奥赛一本通 1312:【例3.4】昆虫繁殖
心余力绌:企业面临的软件供应链安全困境
商城系统APP如何开发 都有哪些步骤
What is the salary of a software testing student?
C Expert Programming Chapter 5 Thinking about Chaining 5.6 Take it easy --- see who's talking: take the Turning quiz
C专家编程 第5章 对链接的思考 5.6 轻松一下---看看谁在说话:挑战Turning测验
C专家编程 第5章 对链接的思考 5.4 警惕Interpositioning
OpenGL绘制圆
入坑软件测试的经验与建议