第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

怎樣判斷Mybatis傳入?yún)?shù)的值

怎樣判斷Mybatis傳入?yún)?shù)的值

暮色呼如 2019-03-13 15:15:57
在查詢數(shù)據(jù)時(shí),想通過循環(huán),每次只查詢10萬條記錄。該怎樣把循環(huán)的參數(shù)傳入SQL中,并利用MyBatis判斷參數(shù),執(zhí)行相應(yīng)的SQL相應(yīng)的代碼://循環(huán)查詢信息@SuppressWarnings({ "unchecked", "rawtypes" })public List<AAA> getLoop(String loopNum) {    return (List)this.getBySqlKey("getLoop",loopNum);}XML:<select id="getLoop" resultMap="AAA" parameterType="String">           SELECT *, ROWNUM RN from tablename        <if test = " _parameter=='1'"> WHERE  RN &lt;=100000  and RN &gt;=1</if>        <if test = " _parameter=='2'"> WHERE  RN &lt;=200000  and RN &gt;=100001 </if></select>一開始if中寫的是:<if test="loopNum == '1'"> WHERE  RN &lt;=100000  and RN &gt;=1 </if><if test="loopNum == '2'"> WHERE  RN &lt;=200000  and RN &gt;=100001 </if>結(jié)果報(bào)錯(cuò):There is no getter for property named 'loopNum' in 'class java.lang.String'。然后按照 Mybatis中傳參報(bào)錯(cuò) 鏈接里的改成_parameter,執(zhí)行之后報(bào)misfired triggers,一直在查詢數(shù)據(jù),感覺是在查整個(gè)庫的數(shù)據(jù),但是一直執(zhí)行不出來。所以想判斷傳入MyBatis參數(shù)的值,應(yīng)該使用哪種方法,可不可以用when標(biāo)簽?
查看完整描述

1 回答

?
慕尼黑8549860

TA貢獻(xiàn)1818條經(jīng)驗(yàn) 獲得超11個(gè)贊

問題已解決,在MyBatis的xml中替換成了when標(biāo)簽,并且在判斷時(shí),將判斷的值加上toString(),參數(shù)名為_parameter,不需要指定成傳入的參數(shù)名,參考代碼如下:


<select id="getLoop" resultMap="AAA" parameterType="String">     

    SELECT *, ROWNUM RN from tablename

        <where>    

            <choose>    

                <when test="_parameter != null and _parameter == '1'.toString()">    

                    RN &lt;=100000  and RN &gt;=1   

                </when>   

                <when test="_parameter != null and _parameter == '2'.toString()">    

                    RN &lt;=200000  and RN &gt;=100001   

                </when>

                <when test="_parameter != null and _parameter == '3'.toString()">    

                    RN &lt;=300000  and RN &gt;=200001   

                </when>        

                <otherwise>    

                    RN &lt;=1  and RN &gt;=1     

                </otherwise>    

            </choose>    

        </where>   

</select>


查看完整回答
反對(duì) 回復(fù) 2019-04-16
  • 1 回答
  • 0 關(guān)注
  • 787 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)