[mybatis]动态sql_bind_绑定

Posted 唐火

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[mybatis]动态sql_bind_绑定相关的知识,希望对你有一定的参考价值。

bind

<!--    public List<Employee>  getEmpsTestInnerParameter(Employee employee);-->
    <select id="getEmpsTestInnerParameter" resultType="com.atguigu.mybatis.bean.Employee">
        <!--<bind name = "_lastName" value = "'%'+lastName+'%'"/>-->
        <bind name = "_lastName" value="'%'+lastName+'%'"></bind>
        <if test = "_databaseId=='mysql'">
            select * from tb1_employee
            <if test = "_parameter!=null">
                where last_name like #_lastName
            </if>
        </if>
        <if test = "_databaseId == 'oracle'">
            select * from employees
            <if test = "_parameter!=null">
                where last_name like #_lastName
            </if>

        </if>

    </select>
    @Test
    public void test04() throws IOException 
        SqlSessionFactory sqlSessionFactory = getSqlSessionFactory();

        SqlSession sqlSession = sqlSessionFactory.openSession();

        try
        
            EmployeeMapperDynamicSQL mapper = sqlSession.getMapper(EmployeeMapperDynamicSQL.class);


            Employee employee = new Employee();

            employee.setLastName("a");

            List<Employee> emps = mapper.getEmpsTestInnerParameter(employee);

            for (Employee e : emps)
            
                System.out.println(e);
            

        finally 

            sqlSession.close();

        
    

以上是关于[mybatis]动态sql_bind_绑定的主要内容,如果未能解决你的问题,请参考以下文章

springBoot整合MyBatise及简单应用

mybatise 实现同一字段多模糊查询

mybatise

mybatise 设置全局变量实例

30.Python面向对象类方法和静态方法动态绑定属性和__slots__限制绑定@property

30.Python面向对象类方法和静态方法动态绑定属性和__slots__限制绑定@property