ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Warren <war...@clarksnutrition.com>
Subject Dynamic Mapped Statement Iterate Question
Date Wed, 22 Nov 2006 00:23:51 GMT
I want to pass a list of objects to a SQL map and get the following SQL 
Statement

SELECT field1, field2, ... FROM table WHERE (field1 = 'value1' AND 
field2 = 'value2') OR (field1 = 'value3' AND field2 = 'value4') ... x n

Is the folowing SQL Map correct?

  <select id="getBatchedItems" parameterClass="java.util.List" 
resultMap="batchedItemsResult">
      SELECT SIL_INV_FK, SIL_INV_CFK, SIL_Description FROM StockInventory
      <dynamic prepend="WHERE">
          <iterate prepend="AND" property="itemList" open="(" close=")" 
conjunction="OR">
              SIL_INV_FK=#itemList[].pk# AND
              SIL_INV_CFK=#itemList[].cpk#
          </iterate>
      </dynamic>
  </select>

itemList would be a List of Item objects each having a property named pk 
and cpk

Thanks,

Warren

Mime
View raw message