ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bing Zou <xiguamaill...@gmail.com>
Subject A question about nullValue in resultMap.
Date Fri, 28 Jan 2005 20:10:19 GMT

So far in iBbatis, when the parameter of the result Bean's setter is
primitive type (for example, setParentCategoryID(long id)),  if the
corresponding column might get a database NULL value during execution,
we have at least three solutions:
1. Change the Bean's setter to use Object type parameter instead of
primitive type. (for example, use setParentCategoryID(Long id_object)
2. Use ResultMap and specify nullValue of the nullable property.
3. Use ResultMap and specify TypeHandler to take care of the returned
Null value.

Obviously solution 1 is not a good one while solution 2 and 3 require
using ResultMap instead of using ResultClass directly.

Now the question is, I want to keep the sqlmap xml file as simple as
possible, so I want to use as much implicit result mapping as
possible. (Because using resultMap will make the xml file a little bit
harder to read, understand, debug and maintain.) I want to avoid
ResultMap even there is nullable column in the SQL statement. So I
hope iBatis could take care of the null values for me.

I am wondering whether the iBatis team will consider adding one more
property to the iBatis configuration file like SkipSettingNullResult.
If SkipSettingNullResult=true, while iBatis sees a Null value returned
from the resultSet, if the corresponding setter is taking a primitive
type parameter, iBatis simply skip this setter and the Bean will use
the default value instead of executing the setter.

I will sincerely appreciate it if the iBatis team could make it happen
in the near future.

Thanks a lot.

View raw message