真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

MyBatis常用語(yǔ)法和注意事項(xiàng)

1. if

創(chuàng)新互聯(lián)公司是一家專業(yè)從事成都網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)的品牌網(wǎng)絡(luò)公司。如今是成都地區(qū)具影響力的網(wǎng)站設(shè)計(jì)公司,作為專業(yè)的成都網(wǎng)站建設(shè)公司,創(chuàng)新互聯(lián)公司依托強(qiáng)大的技術(shù)實(shí)力、以及多年的網(wǎng)站運(yùn)營(yíng)經(jīng)驗(yàn),為您提供專業(yè)的成都網(wǎng)站建設(shè)、營(yíng)銷型網(wǎng)站建設(shè)及網(wǎng)站設(shè)計(jì)開發(fā)服務(wù)!

    This statement would provide an optional text search type of functionality.

     

    

 

2. choose, when, otherwise

    Sometimes we don’t want all of the conditionals to apply, instead we want to choose only one case among many options.

     

    

 

3. set

    The set element can be used to dynamically include columns to update,and leave out others.

     

    A:

    

      update Author

        

          username=#{username},

          password=#{password},

          email=#{email},

          bio=#{bio}

        

      where id=#{id}

    B:

    

    

      update Author set

          username=#{username},

          password=#{password},

          email=#{email},

          bio=#{bio}

      where id=#{id}

    

     

    Ifbiois null

    A.update Author setusername='xx',password='xx',email ='xx'[not has, due to tag will remove it] where id ='x'

    B.update Author set username ='xx',password='xx',email ='xx', where id ='x'

 

4. foreach

    The foreach element is very powerful, and allows you to specify a collection, declare item and index variables that can be used inside the body of the element. It also allows you to specify opening and closing strings, and add a separator to place in between iterations. The element is smart in that it won’t accidentally append extra separators.

 

    

1. trim

  ...

    Sample:

    select * from user 

    

     AND name=#{name}

     AND gender=#{gender}

    

     

    Ifname andgenderare not null, the SQL will be like this:select * from user where name = 'xx' and gender = 'xx'.

 

    prefix:前綴

    prefixoverride: remove 1st AND/OR

     

    update user

    

     name=#{name} ,

     gender=#{gender},  

    

     

    Ifname andgenderare not null, the SQL will be like this:update user set name='xx' , gender='xx' where id='x'.

    suffix: 后綴

    suffixoverride: remove last character “,”

    where:search condition

    Note

    A)Escape character in MyBatis XML

    Sample:

    where id >= 1(wrong)

    where id >= 1(correct)

     MyBatis常用語(yǔ)法和注意事項(xiàng)

    B)mybatis中#{}和${}的區(qū)別

    

    http://www.cnblogs.com/baizhanshi/p/5778692.html

    By default, using the #{} syntax will cause MyBatis to generate PreparedStatement properties and set the values safely against the PreparedStatement parameters (e.g. ?). While this is safer, faster and almost always preferred, sometimes you just want to directly inject a string unmodified into the SQL Statement. For example, for ORDER BY, you might use something like this:

    

 

    ORDER BY ${columnName}

    Here MyBatis won't modify or escape the string.

    

 

    NOTE It's not safe to accept input from a user and supply it to a statement unmodified in this way. This leads to potential SQL Injection attacks and therefore you should either disallow user input in these fields, or always perform your own escapes and checks.


當(dāng)前文章:MyBatis常用語(yǔ)法和注意事項(xiàng)
本文URL:http://weahome.cn/article/pjjpjg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部