Mybatis 註解中使用動態sql

 @Select({"<script>",
            "select * from user",
            "<where>",
            "<if test='userId != null and userId != \"\" '>",
            " and user_id=#{userId}",
            "</if>",
            "<if test='name != null and name != \"\" '>",
            " and name=#{name}",
            "</if>",
            "</where>",
            "</script>"})
    List<User> findAll2(User user);

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章