Java Reference
In-Depth Information
All of the binary dynamic tags share those attributes, and the tags themselves are
listed in table 8.3.
Table 8.3
iBATIS binary dynamic tags
Compares the
property
attribute with
compareProperty
or
compareValue
to
determine if they are equal
<isEqual>
Compares the
property
attribute with
compareProperty
or
compareValue
to
determine if they are equal
<isNotEqual>
<isGreaterThan>
Determines whether the
property
attribute is greater than
compareProperty
or
compareValue
Determines whether the
property
attribute is greater than or equal to
compare-
Property
or
compareValue
<isGreat-
erEqual>
<isLessThan>
Determines whether the
property
attribute is less than
compareProperty
or
compareValue
<isLessEqual>
Determines whether the
property
attribute is less than or equal to
compare-
Property
or
compareValue
Tables are good references but provide lousy examples, so listing 8.4 shows how to
put these tags together.
Listing 8.4
Binary tag example
…
<select id="getShippingType" parameterClass="Cart"
resultClass="Shipping">
SELECT * FROM Shipping
<dynamic prepend="WHERE ">
<isGreaterEqual property="weight" compareValue="100">
shippingType='FREIGHT'
</isEqual>
<isLessThan property="weight" compareValue="100">
shippingType='STANDARD'
</isLessThan>
</dynamic>
</select>
…
In listing 8.4, we create a select statement, and then examine the
weight
property
to determine which shipping type to use for it—less than 100 means standard
shipping, and greater than or equal to 100 means freight.
















