<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mapper.SqlMapper">
<!--    sql语句抽取-->
    <select id="getUserByLike" resultType="com.pojo.entity.UserEntity">
        <!--       select *  from user where name like '%${name}%'
                select *  from user where name like  concat('%',#{name},'%') -->
                select *  from user where name like "%"#{name}"%"
    </select>
    <select id="getUserByList" resultType="com.pojo.entity.UserEntity">
        select *  from user where id in (#{ids})
    </select>
    <select id="getUserByTableName" resultType="com.pojo.entity.UserEntity">
        <!-- 动态设置表名只能用$符号 -->
        select *  from  ${tableName}
    </select>
    <!--
        useGeneratedKeys 设置当前标签中sql使用了自增的主键
        keyProperty 将自增主键的值赋值给映射文件中参数的某个属性值
     -->
    <insert id="insertGeneratedKey"
            useGeneratedKeys="true"
            keyProperty="age"
            parameterType="com.pojo.entity.UserEntity">
        insert into user(name,age,address) value(#{name},#{age},#{address})
    </insert>
</mapper>
