• The same variable name in mybatis #foreach causes the value override problem to be solved


    catalogue background Cause of problem (abbreviated version) Mybatis process source code analysis (long text warning, self access on demand) 1、 Get sqlsessionfactory 2、 Get sqlsession 3、 Execute SQL background Use mybatis to execute the following query: unit testing @Test public void test1() { String resource = “mybatis-config.xml”; InputStream inputStream = null; try { inputStream = […]

  • The mybatis query statement returns operations on objects and generic collections


    Mybatis query statements return objects and generic collections Empmapper mapping interface: package cn.et.mybatis.lesson03; import java.util.List; import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Results; import org.apache.ibatis.annotations.Select; public interface EmpMapper { /** *Query a single piece of data, *The column name of each column will match the corresponding attribute in the EMP entity class *When matching, both sides will be turned […]

  • Solution of inconsistency between method return generic type and resulttype in mybatis


    The generic type returned by the mybatis method is inconsistent with the resulttype When the return value type of the method of xxxmaaper.java is list < a >, and the resulttype of the corresponding SQL in xxxmapper.xml is specified as B object, there will be no package error (even if there is no relationship between […]

  • Mybatis uses foreach to traverse list sets or array arrays


    1、 Preparatory work 1. Db.properties file (remember to modify your database, user name and password) dataSource.driver=com.mysql.jdbc.Driver dataSource.url=jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf8 dataSource.username=blog dataSource.password=blog 2. Master profile <?xml version=”1.0″ encoding=”UTF-8″?> <!DOCTYPE configuration PUBLIC “-//mybatis.org//DTD Config 3.0//EN” “http://mybatis.org/dtd/mybatis-3-config.dtd”> <configuration> <!– Import external profile — > <properties resource=”db.properties”></properties> <!– Alias settings. When not set, the reference should use the full package name. […]

  • Detailed explanation of how to use example under mybatis multithreading


    preface Every time a server receives a request, it scheduls an idle thread from the thread pool to handle it. When spring integrates web, controller and service are usually singletons, so that no matter whether your Example is marked single or multiple, there is only one Example under the same service. The questions are as […]

  • How to implement multiple parameters of mybatis


    The first method: use @ param annotation The usage of this method is that when we write method parameters in the interface, we can add a @ param annotation in front of each parameter. The annotation has a value attribute. We can give a name to the annotated parameter. In the SQL statement, we can […]

  • Process of mybatis using PageHelper plug-in


    This article mainly introduces the process of mybatis using PageHelper plug-in in detail. Through the example code, the introduction is very detailed, which has a certain reference learning value for everyone’s study or work. Friends in need can refer to it 1. Add plug-in dependency <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>5.0.4</version> </dependency> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-autoconfigure</artifactId> <version>1.2.5</version> </dependency> […]

  • How to realize dynamic SQL in mybatis


    One of the most powerful features of mybatis is its dynamic statement function. If you’ve used JDBC or similar frameworks before, you’ll understand how painful it is to connect SQL statement conditions together. Make sure you don’t forget the space or omit a comma after the columns column. Dynamic statements can completely solve these pains. […]

  • Mybatis paging absolute path writing process detailed explanation


    This article mainly introduces the mybatis paging absolute path writing process detailed explanation, the article through the example code introduction is very detailed, for everyone’s study or work has a certain reference learning value, need friends can refer to There are four steps, 1. Download the jar package. The coordinates of Maven are <dependency> <groupId>com.github.pagehelper</groupId> […]

  • Process instance analysis of mybatis executing SQL


    This article mainly introduces the process instance analysis of mybatis executing SQL. The example code is introduced in great detail, which has a certain reference learning value for everyone’s study or work. Friends in need can refer to it This blog focuses on the process of executing SQL in mybatis. Details such as caching and […]

  • Mybatis implementation of SQL query interception modification


    preface One of the functions of interceptors is that we can intercept the calls of some methods. We can choose to add some logic before and after the execution of these intercepted methods, or we can execute our own logic when executing these intercepted methods instead of executing the intercepted methods. An original intention of […]

  • The usage of foreach in mybatis


    I’m doing mybatis mapper.xml File, we often use this situation: dynamic generation of SQL query conditions, this time we can use mybatis foreach The attributes of foreach elements mainly include item, index, collection, open, separator and close. Item: alias for iteration of elements in the collection. This parameter is required. Index: in list and array, […]