Details
-
New Feature
-
Status: Open
-
Major
-
Resolution: Unresolved
-
3.0 Beta 10
-
None
-
None
Description
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.