Mybatis注解中使用if标签

  • Post author:
  • Post category:其他

在SQL语句中加入script标签

@Select({
            "<script>" ,
            "SELECT COUNT(*) FROM category",
            "<if test='query != null and query != \" \" '>",
            "where cat_name like '%${query}%'",
            "</if>",
            "</script>"
    })
    Integer getCount(@Param("query") String query);

版权声明:本文为weixin_43596905原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。