iBATIS sqlmap 与 groupby 如何防止子级上的空记录
需要有关 sqlmap group by 的帮助。当没有子关系时,我得到一个空的子对象,
<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>
有没有办法指定如果没有子关系,则不填充该关系?我的 sql 查询是左外连接,因此将为子项返回空记录。
我想做一些像 isnotNull column="child_ky" 这样的事情,这样孩子就不会被填充
<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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
iBatis 为结果标签提供 notNullColumn 参数:
iBatis offers the notNullColumn parameter for the result tag: