MyBatis@select使用动态SQL

 @Select({"<script> ",
            "select * ",
            "from t_risk_log ",
            "where 1=1 ",
            "<when test='caseNo != null and caseNo != \"\" ' > and case_no = #{caseNo} </when> ",
            "<when test='modelName != null and modelName != \"\" '> and model_name = #{modelName} </when> ",
            "<when test='version != null and version != \"\" ' > and version = #{version} </when> ",
            "<when test='result != null and result != \"\" ' > and result = #{result} </when> ",
            "<when test='abnormal != null and abnormal != \"\" ' > and abnormal = #{abnormal} </when> ",
            "order by response_time desc ",
            "</script> "
    })

 


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