iBatis 使用 resultMap 和parameterMap 的集合
我想在 iBatis 查询中传递一组字符串作为参数映射,并返回结果集的字符串集合。
这可能吗?
示例查询...
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想将字符串列表作为一个参数传递,例如构建
IN(val1,val2...)
查询,那么您应该阅读动态查询,特别是 Iterate 元素。另请参阅。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.对于返回,在
SqlMapClientTemplate
中有queryForList
方法。至于
String
作为参数的Set
,我不知道iBatis是否可以处理;我们为此构建了一个对象,当我遇到这个问题时,它位于 sqlin
子句中,因此我使用逗号分隔值创建了一个循环。或者您可以将
Set
转换为HashMap
并传递它。For the return, In
SqlMapClientTemplate
there is thequeryForList
method.As for the
Set
ofString
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 sqlin
clause, so I made a loop with comma separated values.Or you can convert the
Set
to anHashMap
and pass that.