Java Reference
In-Depth Information
<iterate
property="categoryIds"
open="p.categoryId IN (" close=")"
conjunction="," prepend="BOGUS">
#categoryIds[]#
</iterate>
F Evaluates the
categories
property
Evaluates
productName
property
Evaluates
product-
Description
property
<isNotEmpty property="productName" prepend="AND">
p.name LIKE #productName#
</isNotEmpty>
<isNotEmpty property="productDescription" prepend="AND">
p.description LIKE #productDescription#
</isNotEmpty>
<isNotEmpty property="itemName" prepend="AND">
i.name LIKE #itemName#
</isNotEmpty>
Evaluates item-
Name property
Evaluates
itemDescription
property
<isNotEmpty property="itemDescription" prepend="AND">
i.description LIKE #itemDescription#
</isNotEmpty>
</dynamic>
</select>
B
The opening select tag use aliases to define our parameter class type as prod-
uctSearch and the result class type as product . The SQL fragment is the most
minimal portion of SQL that could be used—for example, in case the user simply
wanted to perform a search that returned everything. The <isEqual> tag is
used outside of the dynamic fragment to determine if a join is needed. We use the
opening dynamic tag , which has a prepend value of WHERE . If no content results
in its body, then the WHERE value specified in the prepend attribute will be ignored.
As a reminder, the dynamic tag also implicitly removes the prepend value of the
first content-producing tag in its body. The <iterate> tag is the thing to note
because it works hand in hand with the dynamic tag to make available all the
necessary SQL components that will provide search constraints around certain cat-
egories. The prepend attribute is needed on the <iterate> tag because of a cur-
rent issue in iBATIS . Content produced by the first nested tag is not counted as the
first prepend and will cause the prepend of the next tag to be ignored. As a rule, be
sure to specify the prepend attribute even if the tag will never need it. The pro-
ductName , productDescription , itemName , and itemDescription properties are
evaluated with the <isNotEmpty> tag to determine if they have a value other than
'' (empty) or NULL .
C
D
E
F
E
Search WWH ::




Custom Search