在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Java  HTML/ LONG型IN操作時mybatis 出現(xiàn)UndeclaredThrowableE

LONG型IN操作時mybatis 出現(xiàn)UndeclaredThrowableException異常

sql精簡如下:

select CHECKLIST_ID

 from A
     WHERE CHECKLIST_ID in
            (1,2))
     order by DT_UPDATE desc

其中CHECKLIST_ID pojo層為LONG型,mybatis resultMap映射如下
<id column="CHECKLIST_ID" jdbcType="DECIMAL" property="checklistId"/>
Example_Where_Clause如下

<when test="criterion.listValue">

              and ${criterion.condition}
              <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                #{listItem}
              </foreach>
            </when>
這樣會報錯     
org.apache.ibatis.exceptions.PersistenceException:
Error querying database. Cause: java.lang.reflect.UndeclaredThrowableException
The error may exist in com/lianpay/risk/check/sqlmap/RiskEventChecklistMapper.xml

當 #{listItem}改成      ${listItem} 就沒有什么問題,即:
  <when test="criterion.listValue">
        and ${criterion.condition}
   <foreach close=")" collection="criterion.value" item="listItem" open="("  separator=",">
              ${listItem}
            </foreach>
  </when>

求解,之前一直那么用的,難道和LONG型有關??
            
回答
編輯回答
笨笨噠

在mybatis中,#{} 相當于是JDBC的preparestatement,是預編譯的,${}不是預編譯的,會有SQL注入的風險,其實你可以看看SQL打印出的log,然后run一下這些SQL,看看哪種是正確的。

select CHECKLIST_ID
 from A
     WHERE CHECKLIST_ID in
            (1,2))
     order by DT_UPDATE desc
select CHECKLIST_ID
 from A
     WHERE CHECKLIST_ID in
            ('1','2'))
     order by DT_UPDATE desc
2018年7月1日 15:00