我在 mybatis 中有动态选择查询,如下所示:
<select id="genericSelect" parameterType="GenericQueryParameter" resultType="hashmap">
SELECT <if test="selectMode != null">${selectMode}</if> ${selectPart}
FROM ${fromPart}
<where>
<if test="fixedWherePart != null">${fixedWherePart}</if>
<if test="wherePart != null">AND ${wherePart}</if>
<if test="initialCondition != null and wherePart == null">AND ${initialCondition}</if>
</where>
<if test="groupByPart != null"> GROUP BY ${groupByPart}</if>
<if test="havingPart != null"> HAVING ${havingPart}</if>
<if test="order != null"> ORDER BY ${order}</if>
</select>
对我来说,在结果中对键进行哈希映射很重要,填充的是列号,而不是列名。是否有可能制作一些自定义处理程序或其他任何东西来做到这一点?
Mybatis 版本是 3.1.1,我正在使用映射器接口来处理查询。