Java Reference
In-Depth Information
Table 8.5
Unary tags (continued)
Determines whether the specified property is a null or empty String , Col-
lection , or String.valueOf() .
<isEmpty>
<isNotEmpty>
Determines whether the specified property is not a null or empty String ,
Collection , or String.valueOf() .
Listing 8.5 shows how to use the unary dynamic SQL tags.
Listing 8.5
Unary tag example
<select id="getProducts" parameterClass="Product"
resultClass="Product">
SELECT * FROM Products
<dynamic prepend="WHERE ">
<isNotEmpty property="productType">
productType=#productType#
</isNotEmpty>
</dynamic>
</select>
In listing 8.5, we create a simple select mapped statement, then use a dynamic
SQL tag to optionally filter the results based on the productType property.
8.2.4
Parameter tags
It is possible to define a mapped statement without a parameter. The parame-
ter tags were created to check whether a parameter has been passed in to the
mapped statement. The tag attributes are shown in table 8.6.
Table 8.6
Parameter tag attributes
prepend
(optional)
This value is used to prepend to the tag's resulting body content. The prepend
value will not be prepended (a) when the tag's resulting body content is empty;
(b) if the tag is the first to produce body content and is nested in a tag with the
removeFirstPrepend attribute set to true; or (c) if the tag is the first to pro-
duce body content following a <dynamic> tag with a prepend attribute value
that is not empty.
open
(optional)
This value is used to prefix to the tag's resulting body content. The open value
will not be prefixed if the tag's resulting body content is empty. The open value is
prefixed before the prepend attribute's value is prefixed. For example, if
prepend="OR " and open="(" , then the resulting combined prefix would be
"OR (" .
Search WWH ::




Custom Search