在ibatis中isNotNull和isNotEmpty的区别

 在ibatis in action 这本书中定义单元标签:

Unary tags examine the state of a bean property and do not perform comparisons
against any other values. The body content is included if the result of the state is
true. All unary tags share the property attribute. The property attribute is used to
specify the property on the parameter object that will be used to examine the
state. The name of the tag indicates the type of state that is being examined. The
unary tag attributes are shown in table 8.4.
All of the attributes in table 8.4 are available in the unary dynamic SQL tags listed
in table 8.5.
Table 8.4 Unary tag attributes
property
(required)
The property of the parameter used for state comparison.
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 remove-
FirstPrepend attribute set to true; or (c) if the tag is the first to produce 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 (".
close
(optional)
This value is used to append to the tag’s resulting body content. The append value
will not be appended if the tag’s resulting body content is empty.
removeFirst-
Prepend
(optional)
This attribute value defines whether the first nested content-producing tag will have
its prepend value removed.
Table 8.5 Unary tags
<isProperty-
Available>
Determines whether the specified property exists in the parameter. With a
bean, it looks for a property. With a map, it looks for a key.
<isNotProperty-
Available>
Checks whether the specified property does not exist in the parameter. With
a bean, it looks for a property. With a map, it looks for a key.
<isNull> Determines whether the specified property is null. With a bean, it looks at
the value of the property getter. With a map, it looks for a key. If the key
does not exist, it will return true.
<isNotNull> Determines whether the specified property is anything other than null. With
a bean, it looks at the value of the property getter. With a map, it looks for a
key. If the key does not exist, it will return false.

 <isEmpty> Determines whether the specified property is a null or empty String, Collection,
or String.valueOf().
<isNotEmpty> Determines whether the specified property is not a null or empty String,
Collection, or String.valueOf().

posted @ 2014-10-07 21:48  王红叶  阅读(1065)  评论(0编辑  收藏  举报