最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Mybatis 條件查詢 批量增刪改查功能

 更新時(shí)間:2017年06月21日 11:13:50   作者:番號(hào)  
這篇文章主要介紹了mybatis 腳本處理語(yǔ)句之條件查詢 批量增刪改查功能,需要的的朋友參考下吧

模糊查詢:

@Select({
    "SELECT * FROM account where account like CONCAT('%',#{query},'%') or email like CONCAT('%',#{query},'%')"
})
Account findAccountByAccountOrMail(@Param("query") String query);

批量添加:

@Insert({
    "<script>" +
        "INSERT INTO company_label(company_id,label_id) values " +
        " <foreach collection=\"item\" item=\"item\" index=\"index\" separator=\",\" > " +
        "    (#{companyId},#{item}) " +
        "  </foreach>" +
        "</script>"
})
void insertLabelForCompany(@Param("companyId") Long companyId,@Param("item") List<Long> item);

批量刪除:

@Delete({
    "<script>delete from company_label where company_id = #{companyId} and label_id in " +
        "<foreach collection = \"item\" item = \"item\" open=\"(\" separator=\",\" close=\")\">" +
        "#{item}" +
        "</foreach>" +
        "</script>"
})
void removeLabelForCompany(@Param("companyId") Long companyId,@Param("item") List<Long> item);

批量修改:

@Update(value = "<script>" + "update banner b set b.display = #{status} where b.id in "+
    "<foreach item = 'item' index = 'index' collection = 'ids' open = '(' separator = ',' close = ')'>#{item}</foreach>" +
    "" +
    "</script>")
int updateStatus(@Param("status") Long status, @Param("ids") Long[] ids);

批量查詢:

@Select({
    "<script>" +
        "select * from product where id in" +
        "<foreach item = 'item' index = 'index' collection = 'idList' open = '(' separator = ',' close = ')'>#{item}</foreach>" +
        "</script>"
})
List<Product> findByIdList(@Param("idList")List<Long> idList);

條件查詢,if里面不僅可以判空,還可以判斷是否滿足某個(gè)條件

@Select({
      "<script>SELECT * FROM company where 1=1 and parent_id = #{companyId} " +
          //平級(jí)
          "<if test = \"isScanSameLevelValue == 1\">and type = #{type}</if>" +
           "<if test = \"isScanSameLevelValue == 0\">and type != #{type}</if>" +

          "</script> "
  })
  List<Company> findCompanyConditional(@Param("isScanSameLevelValue") String isScanSameLevelValue, @Param("isScanParentLevelValue") String isScanParentLevelValue, @Param("companyId") Long companyId, @Param("type") Integer type);

條件查詢:

 */
@Lang(XMLLanguageDriver.class)
@Select({"<script>select DISTINCT p.* FROM `us_product`.`hot_category_surgery` hcs "+
    "LEFT JOIN `us_product`.`product` p ON hcs.`product_id` =p.`id`"+
    "LEFT JOIN `us_product`.`category_surgery` cs on cs.`product_id` =p.`id`"+
    "LEFT JOIN `us_product`.`merchant_product` mp on mp.`product_id` = p.`id`"+
    "LEFT JOIN `us_product`.`org_product` op on op.`product_id` =p.`id`"+
    "where p.`type` =1 and p.`is_for_sale` =1 "+
    "        <if test=\"hId != null\"> and hcs.hot_category_id = #{hId} and p.id = hcs.product_id</if>" + //熱門(mén)類目id
    "        <if test=\"categoryId != null\"> and cs.category_id = #{categoryId} and p.id = cs.product_id</if>" + //類目id
    "        <if test=\"input != null\">    and (p.name like CONCAT('%',#{input},'%') or p.company like CONCAT('%',#{input},'%')) </if> "+  //用戶輸入,包括商品名和店鋪名,模糊
    "        <if test = \" location != null\"> and p.location like CONCAT('%',#{location},'%') </if> "+    //位置..
    "        <if test=\"method != null\">   and mp.filter_id = #{method} and p.id = mp.product_id</if> "+  //篩選條件  手術(shù)方式
    "        <if test=\"org != null\">     and op.filter_id = #{org} and p.id = op.product_id</if> "+   //篩選條件  所屬機(jī)構(gòu)
    "         ORDER BY sale_volume DESC"+
    "        </script>"
})
List<Product> findProductFromLocal(@Param("hId")Long hId,@Param("categoryId")Long categoryId,@Param("input")String input,@Param("method")Long method,@Param("org")Long org,@Param("location")String location);

以上所述是小編給大家介紹的Mybatis 條件查詢 批量增刪改查功能,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • 阿里四面之Spring Exception的原理解析

    阿里四面之Spring Exception的原理解析

    本文給大家介紹阿里四面之Spring Exception的原理解析,本文通過(guò)錯(cuò)誤場(chǎng)景分析給大家詳細(xì)介紹Spring異常處理流程,感興趣的朋友一起看看吧
    2021-10-10
  • SpringBoot實(shí)現(xiàn)PDF轉(zhuǎn)圖片的代碼示例

    SpringBoot實(shí)現(xiàn)PDF轉(zhuǎn)圖片的代碼示例

    在本文中,我們使用SpringBoot演示了如何將PDF文件轉(zhuǎn)換為一張或多張圖片,這些示例演示了如何使用Java編程語(yǔ)言與其他開(kāi)源技術(shù)集成,以實(shí)現(xiàn)各種文件格式之間的轉(zhuǎn)換,感興趣的小伙伴跟著小編一起來(lái)看看吧
    2024-08-08
  • SpringBoot中@Conditional注解的使用

    SpringBoot中@Conditional注解的使用

    這篇文章主要介紹了SpringBoot中@Conditional注解的使用,@Conditional注解是一個(gè)條件裝配注解,主要用于限制@Bean注解在什么時(shí)候才生效,以指定的條件形式控制bean的創(chuàng)建,需要的朋友可以參考下
    2024-01-01
  • 枚舉java語(yǔ)言中的修飾符組合的實(shí)例代碼

    枚舉java語(yǔ)言中的修飾符組合的實(shí)例代碼

    這篇文章主要介紹了枚舉java語(yǔ)言中的修飾符組合,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-07-07
  • HttpClient HttpRoutePlanner接口確定請(qǐng)求目標(biāo)路由

    HttpClient HttpRoutePlanner接口確定請(qǐng)求目標(biāo)路由

    這篇文章主要為大家介紹了使用HttpClient HttpRoutePlanner接口確定請(qǐng)求目標(biāo)路由,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10
  • 淺談Java鎖機(jī)制

    淺談Java鎖機(jī)制

    在多線程環(huán)境下,程序往往會(huì)出現(xiàn)一些線程安全問(wèn)題,為此,Java提供了一些線程的同步機(jī)制來(lái)解決安全問(wèn)題,比如:synchronized鎖和Lock鎖都能解決線程安全問(wèn)題。下面小編就來(lái)詳細(xì)介紹該知識(shí)點(diǎn),需要的朋友可以參考一下
    2021-09-09
  • Hibernate實(shí)現(xiàn)批量添加數(shù)據(jù)的方法

    Hibernate實(shí)現(xiàn)批量添加數(shù)據(jù)的方法

    這篇文章主要介紹了Hibernate實(shí)現(xiàn)批量添加數(shù)據(jù)的方法,詳細(xì)分析了基于Hibernate執(zhí)行批量添加操作的具體步驟與相關(guān)實(shí)現(xiàn)代碼,需要的朋友可以參考下
    2016-03-03
  • 關(guān)于MyBatis結(jié)果映射的實(shí)例總結(jié)

    關(guān)于MyBatis結(jié)果映射的實(shí)例總結(jié)

    結(jié)果集映射主要是為了解決屬性名和類型名不一致的問(wèn)題,下面這篇文章主要給大家介紹了關(guān)于MyBatis結(jié)果映射的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-05-05
  • Spring Boot使用Redisson實(shí)現(xiàn)滑動(dòng)窗口限流的項(xiàng)目實(shí)踐

    Spring Boot使用Redisson實(shí)現(xiàn)滑動(dòng)窗口限流的項(xiàng)目實(shí)踐

    滑動(dòng)窗口限流是一種流量控制策略,用于控制在一定時(shí)間內(nèi)的請(qǐng)求頻率,本文主要介紹了Spring Boot使用Redisson實(shí)現(xiàn)滑動(dòng)窗口限流的項(xiàng)目實(shí)踐,具有一定的參考價(jià)值,感興趣的可以了解一下
    2024-03-03
  • Java及nginx實(shí)現(xiàn)文件權(quán)限控制代碼實(shí)例

    Java及nginx實(shí)現(xiàn)文件權(quán)限控制代碼實(shí)例

    這篇文章主要介紹了Java及nginx實(shí)現(xiàn)文件權(quán)限控制代碼實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-06-06

最新評(píng)論

时尚| 葫芦岛市| 都兰县| 婺源县| 汝南县| 泌阳县| 兴隆县| 东阳市| 温宿县| 新建县| 南雄市| 惠水县| 昌江| 苏尼特右旗| 榆林市| 当阳市| 巴楚县| 买车| 邢台县| 繁昌县| 泰和县| 渑池县| 谷城县| 娱乐| 盘山县| 木兰县| 平陆县| 江都市| 安国市| 佛冈县| 邵武市| 宿州市| 遵化市| 乃东县| 阜新| 白水县| 舞阳县| 前郭尔| 方城县| 天全县| 宽甸|