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

2019-07-20 04:02发布

问题:

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.



标签: java ibatis