↓ Skip to main content

How to iterate over a parameter array in iBATIS SQL query

·83 words·1 min

It’s very simple, however iBATIS documentation does not state this. Suppose you need to issue a query with an IN (….) criterion and you need to pass an array of values into it:


  <select id="getSmth" resultClass="myclass">
    select name, body from myclass_table where name in (
      <iterate conjunction=",">#[]#</iterate>
    )
  </select>

The essential condition for success is - don’t specify the parameterClass attribute in select and don’t specify property in iterate, otherwise the query won’t work.


First published on the old anydoby.com blog on 2007-09-18.