【发布时间】:2014-10-30 07:35:05
【问题描述】:
MySQL查询如下
update group_entity set deleted = 1 where entity_id in (select entity_id from entity where entity_row_id in ('1-424g','1-242T') and entity_type='Data');
此查询在 mysql 中有效。
我的 Ibatis 查询更改如下
<update id="updateData" parameterClass="abc.data.updateDataParameters">
update group_entity set deleted = 1 where entity_id in
<iterate open="(" close=")" conjunction=",">
select entity_id from entity where entity_row_id in
<iterate property="parentIds" open="(" close=")" conjunction=",">
#parentIds[]#
</iterate>
and entity_type = #parentType#
</iterate>
</update>
但 Ibatis 查询无法正常工作,出现错误 ParameterObject or property was not a Collection, Array or Iterator. 错误:
--- 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:
请告诉我如何在迭代中使用 select 语句,如 <iterate>Select id from table</iterate> 返回 id 列表。
我的更新数据参数
class updateDataParameters
{
List<String> parentId;
string parentType;
// with getter and setter and receptive constructor
}
【问题讨论】:
标签: java mysql spring spring-mvc ibatis