
2021MyBatisPlus
chencaw
这个作者很懒,什么都没留下…
展开
-
雪花算法--uuid
1、简单的ID定义,据说varchar(36)就够了,有空查资料验证下。2、在entity中给上UUID的注解就可以了 @TableId(value = "id", type = IdType.ASSIGN_UUID) private String id;原创 2021-12-10 08:42:19 · 888 阅读 · 0 评论 -
Mybatis-Plus新的版本(3.5.1+版本)的使用
为全部完成,,,待续主要功能包括:逻辑删除,创建时间和修改时间逻辑删除:对于重要的数据,不能轻易的执行delete语句进行删除,一旦删除,数据无法恢复,这时可以进行逻辑删除删除正确操作:假删除1、给表添加字段,代表数据是否删除,一般起名isdelete,0代表未删除,1代表删除,默认值为01、主要参考了(1)Mybatis—Plus代码自动生成器超详细讲解(3.5.1+版本)_****^_^****的博客-优快云博客(2)官方主页代码生成器(3.5...原创 2021-12-07 18:16:57 · 12963 阅读 · 4 评论 -
7、mybatis-plus中wrapper的使用
1、例子1,查询非空和大于QueryWrapper<User> wrapper = new QueryWrapper<>();wrapper .isNotNull("name") .isNotNull("email") .ge("age",12);userMapper.selectList(wrapper).forEach(System.out::println);2、例子2,查询单个物体,如:名字为Q.原创 2021-09-16 18:46:36 · 1256 阅读 · 0 评论 -
6、mybatis-plus查询和删除的方式
1、单个byid查询User user = userMapper.selectByID(1);System.out.println(user);2、查询多个IDlist<User> user = userMapper.selectBatchIds(Arrays.asList(1,2,3));users.forEach(System.out::println);3、条件查询HashMap<String, Object> map = new HashMap&原创 2021-09-16 15:05:44 · 504 阅读 · 0 评论 -
5mybatis-plus表的创建时间和修改时间
1、建议一定使用字段gmt_create和gmt_modified字段的类型datetime默认为CURRENT_TIMESTAMP公司对gmt_modified添加更新原创 2021-09-16 14:07:07 · 728 阅读 · 1 评论 -
4mybatis-plus--mapper使用报红(错误提示)的细节处理
基础操作,不应该记录。。。。。。方法一://这一句份重要,ProductMapper,不报红@Component(value = "ProductMapper")public interface ProductMapper extends BaseMapper<Product> {}否则使用的时候会报红 @Autowired private ProductMapper productMapper;方法二:这才是正确用法 @..原创 2021-05-15 07:15:19 · 2832 阅读 · 0 评论 -
3mybatis-plus--测试下数据查询
1、创建controller包2、创建package com.xachen.product.device.controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/** * <p> * 前端控制器 * </p> * * @author原创 2021-04-03 21:02:10 · 172 阅读 · 0 评论 -
2mybatis-plus配置文件和代码生成
参考官网的教程https://mp.baomidou.com/guide/generator.html#使用教程https://www.cnblogs.com/liuyj-top/p/12976396.html1、设计目标数据库测试的product的字段如下:(1)创建数据库create database productdemo;(2)创建表CREATE TABLE product( id int AUTO_INCREMENT PRIMARY KEY,...原创 2021-04-03 20:32:01 · 603 阅读 · 0 评论 -
1mybatis-plus创建项目
mybatis-plus很不错参考https://mp.baomidou.com/guide/install.html#snapshothttps://my.oschina.net/mengwang/blog/49909711、springboot创建项目(1)(2)(3)(4)(5)pom.xml中添加mybatis-plus的依赖,添加的包括:lombok、mybatisplus、mybatis-plus-generator、velocity-engi原创 2021-04-03 19:27:55 · 673 阅读 · 0 评论