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的自增效果
 

三 多数据操作

相关推荐
Yilena5 分钟前
通过mysqldump进行数据迁移时权限不足的解决方案
数据库·学习
韩立学长12 分钟前
基于Springboot酒店管理系统的设计与实现c12044zy(程序、源码、数据库、调试部署方案及开发环境)系统界面展示及获取方式置于文档末尾,可供参考。
数据库·spring boot·后端
han_hanker13 分钟前
统一拦截异常 @RestControllerAdvice
java·开发语言·数据库
herinspace34 分钟前
管家婆软件年结存后快马商城操作注意事项
服务器·数据库·windows
qq_348231851 小时前
MySQL 与 PostgreSQL PL/pgSQL 的对比详解
数据库·mysql·postgresql
玩转数据库管理工具FOR DBLENS1 小时前
DBLens:开启数据库管理新纪元——永久免费,智能高效的国产化开发利器
数据结构·数据库·测试工具·数据库开发
芝麻馅汤圆儿1 小时前
sockperf 工具
linux·服务器·数据库
IndulgeCui1 小时前
金仓数据库征文_使用KDTS迁移mysql至金仓数据库问题处理记录分享
数据库
wsx_iot2 小时前
mysql的快照读和当前读
数据库·mysql
梁萌2 小时前
MySQL分区表使用保姆级教程
数据库·mysql·优化·分区表·分区·partitions