随笔分类 - 后端 / 对象关系映射
摘要:- yml配置 ``` mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 日志 mapper-locations: classpath:mapper/*.xml # 映射 type
阅读全文
摘要:参考 参考 pom.xml <dependency> <groupId>com.github.yulichang</groupId> <artifactId>mybatis-plus-join</artifactId> <version>1.2.4</version> </dependency> y
阅读全文
摘要:官方文档 参考 指定字段的填充方式 public enum FieldFill { /** * 默认不处理 */ DEFAULT, /** * 插入填充字段 */ INSERT, /** * 更新填充字段 */ UPDATE, /** * 插入和更新填充字段 */ INSERT_UPDATE } 实
阅读全文
摘要:官方案例 定义IKeyGenerator的实现 @Configuration public class MybatisPlusConfig { @Bean public IKeyGenerator keyGenerator() { return new DB2KeyGenerator(); } }
阅读全文
摘要:pom.xml <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> </dependency> 配置类 @Configuration @MapperScan("
阅读全文
摘要:pom.xml <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> </dependency> application.yml mybatis-plus: gl
阅读全文
摘要:pom.xml <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> </dependency> <dependency> <groupId>p6spy</gro
阅读全文
摘要:官方文档 官方文档 官方案例 定义sql public class FindOne extends AbstractMethod { @Override public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<
阅读全文
摘要:官方文档 pom.xml,注意mybatis plus版本需高于3.4.3.2 <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</
阅读全文
摘要:官方文档 配置类 @Configuration public class MybatisPlusConfig { @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interce
阅读全文
摘要:官方文档 配置类 @Configuration @MapperScan("org.example.demo15.mapper") public class MybatisPlusConfig { /** * 新多租户插件配置,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfigu
阅读全文
摘要:官方文档 配置类 @Configuration public class MybatisPlusOptLockerConfig { @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusIntercepto
阅读全文
摘要:官方文档 加密数据 @RestController @RequestMapping("/priv") public class PrivController { /** * 加密 * @return */ @RequestMapping("/test") @ResponseBody public S
阅读全文
摘要:官方文档 官方案例 SQL 自动注入器接口 ISqlInjector public interface ISqlInjector { /** * <p> * 检查SQL是否注入(已经注入过不再注入) * </p> * * @param builderAssistant mapper 信息 * @pa
阅读全文
摘要:官方文档 pom.xml <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <version>2.6.1<
阅读全文
摘要:pom.xml <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency
阅读全文
摘要:官方文档 yml mybatis-plus: # Maven 多模块项目的扫描路径需以 classpath*: 开头 (即加载多个 jar 包下的 XML 文件) mapper-locations: classpath*:/mapper/*.xml global-config: db-config:
阅读全文
摘要:实体类 @Data public class User { @TableId(type = IdType.ASSIGN_ID) private Long id; private String name; private Integer age; private String email; } map
阅读全文
摘要:创建表 CREATE TABLE user ( id BIGINT(20) NOT NULL COMMENT '主键ID', company_id BIGINT(20) NOT NULL COMMENT '公司ID', name VARCHAR(30) NULL DEFAULT NULL COMME
阅读全文
摘要:pom.xml <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <version>2.6.1</vers
阅读全文