zoukankan      html  css  js  c++  java
  • Mybatis @Select注解,使用in传入ids数组作为参数 &&当参数为空则不添加该参数的判断

        @Select({
                "<script>",
                    "select",
                    "id, name, user_id",
                    "from label",
                    "where id in",
                        "<foreach collection='ids' item='id' open='(' separator=',' close=')'>",
                        "#{id}",
                        "</foreach>",
                "</script>"
        })
        List<LabelDTO> getLabelsByIds(@Param("ids") List<Long> ids);

    注意:

    1,@Select后面的括号包含大括号

    2, 使用<script>标签

    3,@Select后面大括号中的代码,每行后面使用逗号结束

    2、当参数为空则不添加该参数的判断

    @Select({"<script>",
        "SELECT * FROM tbl_order",
        "WHERE 1=1",
        "<when test='title!=null'>",
        "AND mydate = #{mydate}",
        "</when>",
        "</script>"})
  • 相关阅读:
    系统测试的策略
    POJ1611(并查集)
    POJ2752(KMP)
    POJ3176(DP)
    HDU2579(BFS)
    HDOJ1175(BFS)
    HDOJ1242(BFS)
    HDOJ1180(BFS)
    HDOJ1372(BFS)
    HDOJ2717(BFS)
  • 原文地址:https://www.cnblogs.com/dancser/p/13877697.html
Copyright © 2011-2022 走看看