Left outer join and notNullColumn

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

Left outer join and notNullColumn

Andrew Buckingham

I'm retrieving a left outer join, and using the resultMapping to create the list of subobjects. Obviously, if there are no resulting subobjects, I want the list to be empty; but Ibatis seems to try creating a subobject with null fields.

E.g. considering a parent with children:

<resultMap id="resultParent" class="ParentClass" groupBy="ParentID">
   <result column="ParentID" property="ParentID" type="int"/>
   <result property="Children" resultMapping="thisnamespace.resultChild"/>

<resultMap id="resultChild" class="ChildClass">
  <result column="ChildID" property="ChildID" type="int"/>

...where none of the properties are nullable.

In the case of a left outer join which returns a parent with no children, it seems to me that Ibatis tries to create a ChildClass instance, and set the ChildID to null. Obviously this doesn't work.

So I then discovered some chatter suggesting "notNullColumn" should be used, e.g.

  <result property="Children" resultMapping="thisnamespace.resultChild" notNullColumn="ChildID"/>

...but I'm not convinced that the notNullColumn is even supported. I've downloaded the source from trunk and branches, and neither C# project contains any text like "notNullColumn".

Is this a feature that was never committed to the source?

I'm currently using DataMapper 1.6.2.