Java Reference
In-Depth Information
Table 4.5
Result map attributes
(continued)
Attribute
Description
The
nullValue
attribute specifies the value to be used in place of a NULL value in the
database.
So if a NULL is read from the
ResultSet
, the JavaBean property will be set to the
value specified by the
nullValue
attribute instead of NULL.
The
nullValue
attribute can be any value, but must be appropriate for the property
type.
nullValue
The select attribute is used to describe a relationship between objects so that iBATIS
can automatically load complex (i.e., user-defined) property types.
The value of the statement property must be the name of another mapped statement.
The value of the database column (the column attribute) that is defined in the same
property element as this statement attribute will be passed to the related mapped
statement as the parameter.
Therefore the column must be a supported, primitive type.
This will be discussed in more detail in chapter 5.
select
So, now that you know what the attributes are, how do you use them? Keep read-
ing to find out.
4.4.1
Primitive results
The Java language has eight primitive types (boolean, char, byte, short, int, long,
float, and double), each with its corresponding wrapper class (
Boolean
,
Char
,
Byte
,
Short
,
Integer
,
Long
,
Float
, and
Double
).
While i
BATIS
does not allow you to get a primitive result directly, it does allow
you to get wrapped primitive results. For example, if you want a count of orders
for a customer, you can do it as an Integer, but not as a primitive int, as the next
example shows:
Integer count = (Integer)sqlMap.queryForObject(
"Account.getOrderCountByAccount",
new Integer(1));
<select
id="getOrderCountByAccount"
resultClass="java.lang.Integer" >
select count(*) as value
from order
where accountId = #value#
</select>







