mybatis-plus
帆影匆匆
快乐的程序小白
展开
-
spring 事务源码分析(四)传播机制总览
前言本文主要回答一个问题,spring 如何处理事务的隔离级别事务传播级别事务是逻辑处理原子性的保证手段,通过使用事务控制,可以极大的避免出现逻辑处理失败导致的脏数据等问题。传播级别定义的是事务的控制范围org.springframework.transaction.annotation.Propagation其中嵌套事务单独写篇博客叙述源码分析在 spring 事务源码(二)一文中已经提到了一个关键的方法org.springframework.transaction.support.A原创 2021-12-30 14:33:51 · 336 阅读 · 0 评论 -
Mybatis-plus 多表联查实现(非手写sql)
项目地址https://gitee.com/hanscoding/mybatis-plus-helper引入依赖 <dependency> <groupId>io.github.githgf</groupId> <artifactId>mybatis-plus-helper</artifactId> <version>0.0.2</version>原创 2021-12-17 16:10:38 · 2670 阅读 · 1 评论 -
mybatis-plus 自定义UpdateWrapper(二)实现列的case set
前言小编在crud业务中会遇到case set的场景,update `TD_XXX`set`status` = case `id` when 12 Then 1 when 13 Then 2 when 14 Then 1 endwhere `id` in (12,13,14)一般来说都是写在xml中,但是其实mybatis-plus也可以<dependency> <groupId>org.mybatis.spring.boot&l原创 2021-11-18 09:59:31 · 1340 阅读 · 0 评论 -
mybatis-plus 自定义UpdateWrapper(一)实现列自增
前言crud业务中难免会有列的自增、自减,如果项目中集成的是mybatis-plus的话不做任何修改大概只有两种方案使用UpdateWrapper拼接直接写原生sql到xml中但是两种方法都不优雅,因为都需要写死列名字(如果优雅我还写啥文章。。。)那么我就尝试能够实现自定义的LambdaUpdateWrapper<dependency> <groupId>org.mybatis.spring.boot</groupId>原创 2021-11-17 13:55:33 · 5999 阅读 · 2 评论 -
mybatis-plus 自定义QueryWrapper(一)实现查询函数
前言以下所有代码和观点来源均为 <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.0.1</version> </depend原创 2021-11-08 16:40:01 · 6152 阅读 · 0 评论 -
spring 事务源码(三)如何保证被@Transactional标记方法中的所有sql都在一个事务内
核心问题spring 如何保证被事务注解标记方法中的所有sql都在一个事务内测试代码还是之前的代码,但是这次得改下,想办法让sql抛出异常<select id="getNum" resultType="java.lang.Integer"> select count(*) from ss where 1 = 1; </select> @Transactional public void test(){原创 2021-09-08 16:44:41 · 966 阅读 · 0 评论 -
spring 事务源码(二)事务切面详细
前言上文说到事务注解处理的切面如何注入、解析,这篇文章说下具体事务切面如何运行事务测试代码环境jdk 1.8spring boot 2.0.4mybatis-plus-boot-starter 3.4.1@Componentpublic class WebHelper { @Autowired CourseItemServiceImpl courseItemService; @Transactional public void test(){原创 2021-08-26 10:38:44 · 735 阅读 · 0 评论 -
MybatisPlusExcepection: can not find lambda cache for this property [XX] for entity [xxx]
项目有用到mybatis-plus还是挺香的,但是遇到一个坑com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this property [dbName] of entity []意思是实体类enetity及其字段没有缓存或者说指定字段没有缓存这个需要具体问题具体分析,得先找到在哪缓存的?什么时候缓存的?问题和解决方案我这里的问题是因为继承太多正常是一个mapp原创 2020-09-17 17:57:51 · 12845 阅读 · 6 评论