There are hidden dangers in using Mybatis-Plus, it’s so tricky!

Author: confused codeLink: https://juejin.cn/post/7156428078061895710 Foreword MP has been controversial since its emergence. It feels like there have always been two voices. like: It is very convenient. Sql is automatically spliced through functions. There is no need to go to XML or use tags. The Sql written in one minute can now be written in one […]

8 Reverse engineering of Mybatis

Forward engineering: First create Java entity classes, and the framework is responsible for generating database tables based on the entity classes. Hibernate supports forward engineering Reverse engineering: create a database table, and the framework is responsible for reversely generating the following resources based on the database table java entity class Mapper interface Mapper mapping file […]

,Multiple data sources + Mybatisplus + Sharding JDBC split tables in the same database

Horizontal table sharding is to split the data of the same table into multiple tables according to certain rules in the same database. Multiple data sources use the dynamic-datasource of mybatis-plus. The sharding-jdbc database and table sharding are used. The database connection pool management is alibaba’s druid-spring-boot-starter Tables in the same database Table of Contents […]

Springboot integrates redis, mybatis-plus and websocket exception framework code encapsulation

In the process of software development, a well-encapsulated, concise and elegant Family Bucket framework can greatly improve the work efficiency of developers, while also reducing the complexity of the code and making it easier to maintain in the future. The source code involved in this article is at the end of the article, with a […]

Use myBatis to create tables based on entity classes in Java

①: Introduce dependencies (pom) 1. Introduce basic dependencies <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jdbc</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> 2. Introduce mysql, myBatis, and data sources <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.26</version> </dependency> <!–Plug-in to create tables–> <dependency> <groupId>com.gitee.sunchenbin.mybatis.actable</groupId> <artifactId>mybatis-enhance-actable</artifactId> <version>1.5.0.RELEASE</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.3.0</version> […]

How does Mybatis-plus use interceptors to get SQL and parse it?

1. Custom interceptor package com.tigeriot.mqtt.config.mybatis; import cn.hutool.json.JSONUtil; import com.tigeriot.mqtt.common.CacheDev; import com.tigeriot.mqtt.common.CacheMQ; import com.tigeriot.mqtt.entity.log.DevLog; import com.tigeriot.mqtt.service.DevLogService; import com.tigeriot.mqtt.util.JsonUtils; import com.tigeriot.mqtt.util.SQLParseUtils; import org.apache.ibatis.binding.MapperMethod; import org.apache.ibatis.executor.Executor; import org.apache.ibatis.mapping.BoundSql; import org.apache.ibatis.mapping.MappedStatement; import org.apache.ibatis.plugin.*; import org.apache.ibatis.session.Configuration; import org.apache.ibatis.session.defaults.DefaultSqlSession; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.stereotype.Component; import java.lang.reflect.Method; import java.lang.reflect.Parameter; import java.util.Arrays; import java.util.Date; import java.util.Map; import java.util.Properties; […]

Dao development of Mybatis

Mybatis core objects SqlSessionFactoryBuilder SqlSessionFactoryBuilder is used to create SqlSessionFacoty. Once SqlSessionFacoty is created, SqlSessionFactoryBuilder is no longer needed. Because SqlSession is produced through SqlSessionFactory, SqlSessionFactoryBuilder can be used as a tool class. The best scope of use is local variables in static code blocks. SqlSessionFactory SqlSessionFactory is an interface that defines different overloaded methods […]