ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cowwoc <cow...@bbs.darktech.org>
Subject Re: "JDBC requires that the JdbcType must be specified for all nullable parameters"
Date Thu, 08 Apr 2010 02:16:33 GMT

     Done: https://issues.apache.org/jira/browse/IBATIS-772

Thanks,
Gili

On 07/04/2010 9:54 AM, Clinton Begin wrote:
> Null parameters are allowed, so we can't fail upon them.  To maintain 
> compatibility with string based calls against map parameters, we don't 
> distinguish between a null keyed entry in the map and no keyed entry 
> at all.
>
> I'd be willing to consider this change, but it's one of those things 
> that has always been true, and so some people might depend on this 
> behavior, especially those that don't use mapper interfaces.
>
> If you like, file a feature request in Jira.
>
> Clinton
>
> On Tue, Apr 6, 2010 at 10:27 PM, cowwoc <cowwoc@bbs.darktech.org 
> <mailto:cowwoc@bbs.darktech.org>> wrote:
>
>     On 07/04/2010 12:09 AM, cowwoc wrote:
>
>         Hi,
>
>            I am getting an error message:
>
>            "JDBC requires that the JdbcType must be specified for all
>         nullable parameters [...] The error may involve <mapper
>         name>-Inline". Granted, telling me the mapper name is useful
>         but I believe we can improve this error message in two regards:
>
>         1. I mistakenly read "nullable parameters" as "nullable
>         columns" and wasted time looking for problems in my database
>         schema. I wonder if others have made a similar mistake...? Is
>         it possible to rephrase this as follows? "Mapper methods
>         cannot accept null arguments without a properly configured
>         JdbcType. Either specify a JdbcType or refrain from passing in
>         null."
>
>         2. I noticed that when this exception is thrown iBatis has
>         quite a bit more information available to it. Is it possible
>         to add the following information to the error message?
>
>         Prepared statement: "SELECT * FROM animals WHERE name = ? AND
>         age > ?", parameter #2 was null
>
>            This would enable me to track down exactly which parameter
>         was equal to null.
>
>         Thank you,
>         Gili
>
>
>     The error message turned out to be even more misleading than I
>     first expected. I had this code:
>
>        @Select("SELECT value FROM seat_properties WHERE seat = #{seat}
>     AND key = #{key}")
>        String get(short seat, String key);
>
>     I wrongly assumed that iBatis would grab the parameter names from
>     the method declaration. Instead, it names the parameters #{1},
>     #{2}, etc. When iBatis tried invoking this method, it couldn't
>     find #{seat} so it assigned it a null value and failed with the
>     aforementioned error message. I had to use the @Param annotation
>     to fix this:
>
>        @Select("SELECT value FROM seat_properties WHERE seat = #{seat}
>     AND key = #{key}")
>        String get(@Param("seat") short seat, @Param("key") String key);
>
>     Shouldn't iBatis fail-fast when the parameter it is looking up
>     ("seat" in my case) is missing, as opposed to assigning it a null
>     value? A nice error message would be "Could not find parameter
>     #{seat}. The following parameters are defined: #{1}, #{2}." I
>     would have caught on fairly quickly with that error message.
>
>
>     Gili
>
>     ---------------------------------------------------------------------
>     To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>     <mailto:user-java-unsubscribe@ibatis.apache.org>
>     For additional commands, e-mail: user-java-help@ibatis.apache.org
>     <mailto:user-java-help@ibatis.apache.org>
>
>


Mime
View raw message