mybatis入门

- 动态 SQL
    - if 条件判断

        ```xml
         
        ```
    - choose (when, otherwise)条件查询

        ```xml
         
        ```
    - trim (where, set)
        - where:元素只会在至少有一个子元素的条件返回 SQL 子句的情况下才去插入“WHERE”子句。而且,若语句的开头为“AND”或“OR”,where 元素也会将它们去除。

            ```xml
            
            ```
        - trim:通过自定义 trim 元素来定制 where 元素的功能

            ```xml
            
            ... 
            
            ```
        - set:元素可以用于动态包含需要更新的列,而舍去其它的

            ```xml
            
            update Author
                
                username=#{username},
                password=#{password},
                email=#{email},
                bio=#{bio}
                
            where id=#{id}
            
            ```
    - foreach:对一个集合进行遍历,通常是在构建 IN 条件语句的时候

        ```xml
        
        ```
    - bind:元素可以从 OGNL 表达式中创建一个变量并将其绑定到上下文

        ```xml
        
        ```

你可能感兴趣的:(mybatis入门)