null testing using HashMap parameters

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

null testing using HashMap parameters

gfrancis1@gmail.com
Using Mybatis 3, I am passing a Map as parameters into the statement:

  <select id="selectReportableForUser"
parameterType="java.util.HashMap"
resultType="com.mycompany.myproduct.model.Level">
    select level_id, strata_id, level_name, parent_level
    from public.level
    <if test="#{parent_level} != null">
            where level_id= #{parent_levels}
            </if>
  </select>

If I pass in a Map with no entry for "parent_level" this executes
fine, with the following debug appearing in the console:
25 Oct 2010 13:21:05,716 DEBUG [PreparedStatement] ==>  Executing:
select level_id, strata_id, level_name, parent_level from public.level
where level_id= ?
25 Oct 2010 13:21:05,716 DEBUG [PreparedStatement] ==> Parameters:
null

So, is 'parent_level' null or not null according to myBatis?