I used mybatis-spring-1.0.3-SNAPSHOT mybatis-3.0.6 spring3.0.6.I tried to delete record from a table like this:
OK I see a few problems. First, when setting a null parameter into a Prepared Statement or a Callable Statement MyBatis needs to know the jdbc type. Like this,
#{myNullParamenter, jdbcType=VARCHAR}
You're also generating your 'in clause incorrectly. You need to use the foreach tag to only generate list of the values. Move the "ID IN" part out of the foreach tag.
<if test="ids !=null and ids.length > 0">
ID IN
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
I would also recommend against using HashMaps. The new Mapper classes are much better.
The problem is that since the 3.0.x versions the default JDBC type for null parameters is Types.OTHER
which not supported by some JDBC drivers like Oracle 10g.
Here a post that explain this issue.
The solution I found is very simple, I set jdbcTypeForNull
to NULL
in the configuration file.
<configuration>
<properties resource="mybatis-config.properties" />
<settings>
<setting name="jdbcTypeForNull" value="NULL" />
</settings>
<environments default="development">
....
</environments>
<mappers>
....
</mappers>
</configuration>