问题
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