iBatis using a set for a resultMap as well as a parameterMap

谁说胖子不能爱 提交于 2019-12-11 03:48:08

问题


I want to pass a Set of Strings in an iBatis query for the parameter map as well as return a collection of strings for the result set.

Is this possible?

Example queries ...

SELECT * FROM some_table t WHERE t.some_column IN (values);

UPDATE some_table t SET t.some_column = 'some_value' WHERE t.other_column IN (values);

Walter


回答1:


If you want to pass a List of Strings as one parameter, for example for building a IN(val1,val2...) query, then you should read about dynamic queries, in particular the Iterate element. See also.




回答2:


For the return, In SqlMapClientTemplate there is the queryForList method.

As for the Set of String as parameter, I do not know if iBatis handles that; we built an object for that, and when I faced that problem it was in a sql in clause, so I made a loop with comma separated values.
Or you can convert the Set to an HashMap and pass that.



来源:https://stackoverflow.com/questions/2729673/ibatis-using-a-set-for-a-resultmap-as-well-as-a-parametermap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!