MyBatisPlue-03

一 映射匹配兼容机制

1.映射数据库的字段名

问题描述:

当数据库表字段和实体类的属性名称出现不匹配时:

解决:

知识点:

2.忽略实体类的部分字段

问题描述:

当要表示如 显示用户是否在线等消息,,这类消息不在数据库中存储,但是在实体类中应用

解决:

知识点:

3. 关闭部分字段的查询

问题描述:

默认查询会直接查询出所有数据,例如密码数据是不应该被查询的

解决:

知识点:

4.表名与实体类名不同步

问题描述:

解决:

知识点:

还可以在配置文件中 搞全局配置。。。

java 复制代码
spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/www?serverTimezone=UTC
    username: root
    password: root
  main:
    banner-mode: off

mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  global-config:
    banner: false
    db-config:
      table-prefix: tbl_
      id-type: assign_id

二 id自动生成机制

雪花算法:格式如下图

字段前加:@TableId(type = IdType.AUTO)

全局配置:

java 复制代码
spring:
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/www?serverTimezone=UTC
    username: root
    password: root
  main:
    banner-mode: off

mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  global-config:
    banner: false
    db-config:
      table-prefix: tbl_   //全局配置实体类映射的数据库表前缀
      id-type: assign_id   //全局配置数据库表中id的自增效果
 

三 多数据操作

相关推荐
qq_192779872 小时前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python
u0109272712 小时前
使用Plotly创建交互式图表
jvm·数据库·python
爱学习的阿磊2 小时前
Python GUI开发:Tkinter入门教程
jvm·数据库·python
tudficdew3 小时前
实战:用Python分析某电商销售数据
jvm·数据库·python
sjjhd6523 小时前
Python日志记录(Logging)最佳实践
jvm·数据库·python
Configure-Handler3 小时前
buildroot System configuration
java·服务器·数据库
2301_821369614 小时前
用Python生成艺术:分形与算法绘图
jvm·数据库·python
电商API_180079052475 小时前
第三方淘宝商品详情 API 全维度调用指南:从技术对接到生产落地
java·大数据·前端·数据库·人工智能·网络爬虫
2401_832131955 小时前
Python单元测试(unittest)实战指南
jvm·数据库·python
打工的小王5 小时前
redis(四)搭建哨兵模式:一主二从三哨兵
数据库·redis·缓存