MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » Ibatis语句怎么使用if判断

Ibatis语句怎么使用if判断

www.MyException.Cn  网友分享于:2013-02-01  浏览:1137次
Ibatis语句如何使用if判断
Ibatis语句如何使用if判断,哪位大虾有例子!

------解决方案--------------------
isNotNull
isEmpty
isGreaterEqual
isNotNull
isLessEqual
……

------解决方案--------------------
学习了。
------解决方案--------------------
XML code

<select id="getPersonsByName" resultClass="com.unmi.Person">       
      select id as id,name as name,passwd as passwd from person       
        <dynamic prepend="WHERE">       
            <isNotNull prepend="AND" property="name">       
                  (name like #name#)       
            </isNotNull>       
        </dynamic>       
</select>

------解决方案--------------------
XML code


<!-- find user list page -->
    <select id="find-count-of-users" parameterClass="User" resultClass="int">
        select count(*) from t_user
            <dynamic prepend="where">
                <isNotEqual property="type" compareValue="-1" prepend="AND">
                    user_type = #type#
                </isNotEqual>
                <isNotEmpty property="userName" prepend="and">
                    user_name like '%$userName$%'
                </isNotEmpty>
                <isNotEqual property="state" compareValue="3" prepend="AND">
                    user_state = #state#
                </isNotEqual>
                <isNotEqual property="usedSpaceSize" compareValue="-1" prepend="AND">
                    user_used_space_size >= #usedSpaceSize#
                </isNotEqual>
            </dynamic>
    </select>

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有