Fuzzy query syntax for several databases

<if test="name ! = null and name ! = ''"> AND a.name LIKE <if test="dbName == 'oracle'">'%'||#{name}||'%'</if> <if test="dbName == 'mssql'">'%'+#{name}+'%'</if> <if test="dbName == 'mysql'">concat('%',#{name},'%')</if> </if>Copy the code

Mybatis batch insert:

Dao layer: Integer insertBatch(List <Entity> List);Copy the code

xml:

<insert id ="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"> insert into dbName Field 1, field 2 of the database table.. Separator =","> (#{item.entity ()}, 2 # {item. The Entity (field)}, # {item. The Entity fields (n)}) < / foreach > < / insert >Copy the code

Delete mybatis batch

Dao layer int deleteBatch(@param ("ids") List<BigInteger> ids);Copy the code

XML:

<delete id="deleteBatch"> delete FROM DBname WHERE id IN <foreach item="item" collection="ids" open="(" separator="," close=")"> #{item} </foreach> </delete>Copy the code