mybatis通过注解使用动态sql

@Select({"<script>",
        "sql语句"+
        "</script> "})回车会自动拼接

代码⬇️

 @Select({"<script>",
            "SELECT id,username,client_id,password,mobile,email,account_non_locked from bhcz_user" +
                    "<where>\n" +
            "            <if test=\"bhczUser.username!='' and bhczUser.username!=null\">\n" +
            "               AND username LIKE CONCAT('%',#{bhczUser.username},'%')\n" +
            "            </if>\n" +
            "            <if test=\"bhczUser.mobile!='' and bhczUser.mobile!=null\">\n" +
            "               AND mobile LIKE CONCAT('%',#{bhczUser.mobile},'%')\n" +
            "            </if>\n" +
            "        </where>"+
            " </script> "})

 


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