There have been similar reports in the past.  Would you try the latest
version (2.3) to see if you still have the error?  Also, this known bug may
be related:

http://issues.apache.org/jira/browse/IBATIS-357

It might seem unrelated on the surface, but I belive the error maybe in the
same area of the code.

Anyway, let us know if it's still broken with the latest version.  If we can
get a reproducible test case, then we can take a look at it.

Jeff Butler


On 6/28/07, lee_will <[EMAIL PROTECTED]> wrote:


I came across the issue when I used TypeHandler in <resultMap> and I
believe
it's a bug. Here is the case:
There're two columns, "date_read" and "date_created" in the "messages"
table
(MySql database), they are type of "Datetime" and "Timestamp"
respectively.
I was trying to convert them to string using type handler
(SimsDateToCharTypeHandler).

<typeAlias alias="myDateToChar"
type="myPackage.util.SimsDateToCharTypeHandler" />

<resultMap id="messageInfoResult" class="myPackage.MassageInfo">
       <result property="dateRead" column="date_read"
typeHandler="myDateToChar "/>
       <result property="dateCreated" column="date_created"
typeHandler="myDateToChar "/>

   <!-- more mapping -->
</resultMap>


<select id="getMessagesByUserName" resultMap="messageInfoResult" >
SELECT
   date_read, date_created
FROM messages
</select>

"date_read" can be "null" value but "date_created" is always populated
with
"current time" in database. When the order of elements in <resultMap> is
as
above and if "date_read" is NULL,  "dateCreated" property in "MassageInfo"
object will be NULL. This is not right since "date_created" HAS value so
that "dateCreated" property should be something like "07/01/2006 11:30",
rather than "NULL".

However if I reverse the order of elements in <resultMap>, i.e.,
<resultMap id="messageInfoResult" class="myPackage.MassageInfo">
<!-- order of these two is reversed -->
       <result property="dateCreated" column="date_created"
typeHandler="myDateToChar "/>
       <result property="dateRead" column="date_read"
typeHandler="myDateToChar "/>
   <!-- more mapping -->
</resultMap>

Then I'll get correct result, e.g., dateCreated could be "07/01/2006" but
"dateRead" is null.

The iBatis version is 2, I'm not sure if you've fixed it in the latest
version.
--
View this message in context:
http://www.nabble.com/iBatis-bug-report-tf3995995.html#a11348464
Sent from the iBATIS - Dev mailing list archive at Nabble.com.


Reply via email to