You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Warren <wa...@clarksnutrition.com> on 2006/11/22 01:23:51 UTC
Dynamic Mapped Statement Iterate Question
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
RE: Dynamic Mapped Statement Iterate Question
Posted by Poitras Christian <Ch...@ircm.qc.ca>.
This is ok.
Christian
-----Original Message-----
From: Warren [mailto:warren@clarksnutrition.com]
Sent: Tuesday, 21 November 2006 19:24
To: user-java@ibatis.apache.org
Subject: Dynamic Mapped Statement Iterate Question
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