用法
<isNotNull property="videoIdList" prepend="and">
<![CDATA[ video_id IN ]]>
<iterate property="videoIdList" open="(" close=")" conjunction=",">
<![CDATA[ #videoIdList[]# ]]>
</iterate>
</isNotNull>
<iterate property="videoIdList">不加 property会报如下异常信息
“org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
— The error occurred in appName/sql-material.xml.
— The error occurred while preparing the mapped statement for execution.
— Check the material.list.
— Check the parameter map.
— Cause: com.ibatis.sqlmap.client.SqlMapException: ParameterObject or property was not a Collection, Array or Iterator.; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
— The error occurred in appName/sql-material.xml.
— The error occurred while preparing the mapped statement for execution.
— Check the material.list.
— Check the parameter map.
— Cause: com.ibatis.sqlmap.client.SqlMapException: ParameterObject or property was not a Collection, Array or Iterator.”
本文介绍使用MyBatis框架时,对参数进行校验的方法,特别是如何正确配置和使用迭代器来避免运行时错误。当传递给SQL映射文件的参数不是集合、数组或迭代器类型时,会抛出异常。
842

被折叠的 条评论
为什么被折叠?



