Need help with sqlmap group by. Im getting an empty child object when there is no child relationship
<resultMap id="GrpMap" class="Grp" groupBy="GroupId">
<result column="grp_id" property="GroupId" jdbcType="UUID"/>
<result column="nm" property="name" jdbcType="VARCHAR"/>
<result property="children" resultMap="Groups.childMap"/>
</resultMap>
<resultMap id="childMap" class="child">
<result column="child_ky" property="childKey" jdbcType="UUID"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
</resultMap>
is there a way of specifying that if there is no children then not to populate the relationship? my sql query is a left outer join so will return null records for the child.
I want to do something like isnotNull column="child_ky" so the child does not get populated
<resultMap id="GrpMap" class="Grp" groupBy="GroupId">
<result column="grp_id" property="GroupId" jdbcType="UUID"/>
<result column="nm" property="name" jdbcType="VARCHAR"/>
<isnotnull child_ky>
<result property="children" resultMap="Groups.childMap"/>
</inotnull>
</resultMap>
iBatis offers the notNullColumn parameter for the result tag:
<resultMap id="GrpMap" class="Grp" groupBy="GroupId">
[...]
<result property="children" resultMap="Groups.childMap" notNullColumn="child_ky"/>
</resultMap>