[ 
http://issues.apache.org/jira/browse/IBATIS-282?page=comments#action_12414247 ] 

z. zhong commented on IBATIS-282:
---------------------------------

I checked it again. It turned out the param type was java.sql.Date instead of 
java.util.Date. Changing the type to java.util.Date worked. But now, the 
question is why java.sql.Date doesn't cause truncation in the first case as 
well. Shouldn't the expansion be independent of the presence of dynamic sql?

I obtained the sql fragment by deliberately introducing an error in the 
statement, and observing the exception message from the JDBC driver which 
includes the sql. I didn't have time to figure out how to get iBatis to log the 
sql.

Thanks.


> truncation of date property values in the presence of dynamic sql
> -----------------------------------------------------------------
>
>          Key: IBATIS-282
>          URL: http://issues.apache.org/jira/browse/IBATIS-282
>      Project: iBatis for Java
>         Type: Bug

>   Components: SQL Maps
>     Versions: 2.1.7
>  Environment: linux, mysql, java 1.5
>     Reporter: z. zhong
>  Attachments: test.zip
>
> strange interaction between Java.util.Date parameters and dynamic sql.
> query 1:
>     select
>         ...
>     where
>          ...
>          and rd.event_time       <= #endTime#
> the generated SQL is
>         ...
>         and rd.event_time       <= '2006-03-30 18:33:46'
>         
> so far so good.
> query 2:
> just add an extra dynamic sql at the end:
>     select
>         ...
>     where
>          ...
>                  and rd.event_time       &lt;= #endTime#
>                   <iterate prepend="and" property="done" open=" 
> rd.is_complete in (" conjunction="," close = ")">#done[]#</iterate>
>         
> and the SQL becomes
>         ...
>         and rd.event_time       <= '2006-03-30'
>         and ...
> The date value has been truncated.
> Notes:
> * i've tried other dynamic sql elements: isNotEmpty, etc., and got the same 
> problem.
> * insert seems to work.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to