zoukankan      html  css  js  c++  java
  • 【MyBatis】动态 SQL

    【MyBatis】动态 SQL

    转载:

    目录

    ==========================================

    1、if

    2、choose when otherwise

    3、trim where set

    4、foreach

    5、bind

    ==========================================

    1、if

        <select id="selectAuthor" resultType="Author">
            select * from author where sex = 'male'
            <if test="name != null">
                and name = #{name}
            </if>
        </select>

    5、bind

    基本参数

    public List<Blog> selectBlogList(@Param("title") String title);
        <select id="selectBlogList" resultType="Blog">
            <bind name="titlePattern" value="'%' + title + '%'"/>
            select * from blog 
            <where>
                <if test="title != null">
                and title like #{titlePattern}
                </if>
            </where>
        </select>

    对象参数

    public List<Blog> selectBlogList(Blog blog);
    <select id="selectBlogList" resultType="Blog">
            <bind name="titlePattern" value="'%' + _parameter.getTitle() + '%'"/>
            select * from blog 
            <where>
                <if test="title != null">
                and title like #{titlePattern}
                </if>
            </where>
        </select>
  • 相关阅读:
    素数
    超级素数
    SUMMARIZE 6.1
    广度优先搜索与八字码问题
    poj2352
    poj1198
    康托展开
    STL里的内存池实现
    构造函数,C++内存管理,内存泄漏定位
    内联函数,宏定义,内存对齐,类型转换
  • 原文地址:https://www.cnblogs.com/yangchongxing/p/10498669.html
Copyright © 2011-2022 走看看