[
http://issues.apache.org/jira/browse/IBATIS-297?page=comments#action_12413320 ]
Jeff Butler commented on IBATIS-297:
------------------------------------
This can get complex depending on how you lay out your parameter object. But I
think with the new nested iterate support you should be able to achieve just
about anything you need. Here's one way to do it with a nested iterate (this
would work now with a build of iBATIS from source in SVN, it will be released
with iBATIS 2.2.0):
List values = new ArrayList();
values.add("1");
values.add("2");
values.add("3");
Map condition = new HashMap();
map.put("condition", "someField in");
map.put("value", values);
List conditions = new ArrayList();
conditions.add(condition);
Map parms = new HashMap();
parms.put("conditions", conditions);
queryForList("statementId", parms);
select *
from mytable
<iterate prepend="where" conjunction="and" property="conditions">
$conditions[].condition$
<iterate open="(" close=")" conjunction="," property="conditions[].value">
#conditions[].value[]#
<iterate>
</iterate>
This should generate:
select *
from myTable
where someField in("1", "2", "3")
Again, this won't work with an official iBATIS release until iBATIS 2.2.0 - but
you could check the source out of SVN and build it now.
> iBATIS doesn't remap sql fully
> ------------------------------
>
> Key: IBATIS-297
> URL: http://issues.apache.org/jira/browse/IBATIS-297
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Versions: 2.1.5
> Reporter: adamb
>
> iBATIS doesn't remap parameters.
> If I have statement with remapResults="true":
> select * from mytable where $dynamicWhereClause$
> and pass in the following two parameters:
> dynamicWhereClause #key#='abc'
> key
> java.lang.String="abc"
> Then the remap puts the #key# in the sql directly, rather than rechecking the
> statement to determine what the parameters will be, so gives the error
> message:
> java.sql.SQLException: ORA-00911: invalid character
> because it hasn't recognised the new hash parameters.
> Version tested on:
> iBATIS 2.1.5
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira