0
我需要在ibatis中有继承映射。在ibatis的文档,我所学到的是,我们可以比较的列的值来调用的结果映射的鉴别标签中的子图像如下:基于Ibatis select语句中列值的动态查询?
<resultMap id="map">
<discriminator javaType="java.lang.Integer" column="type">
<subMap resultMap="submap1" value="1" />
<subMap resultMap="submap2" value="2"/>
<subMap resultMap="submap3" value="3"/>
</discriminator>
</resultMap>
在上面的结果映射,子图列映射到不同的对象。
但我想比较select语句本身的列的值,以便我可以获取所需的列。一些类似如下:
<select id="load" resultMap="map">
select mt.id,mt.name, mt.type
<here we have to check the value of type column returned dynamically>
<if type = "1">
table1.column1, table1.column2 ... table1.columnN
</if>
<if type = "2">
table2.column1, table2.column2 ... table2.columnN
</if>
</here>
from main_table mt
LEFT OUTER JOIN TABLE1 table1 ON mt.id=table1
LEFT OUTER JOIN TABLE2 table2 ON mt.id=table2
where mt.id=#value#
</select>
这只是我的要求算法。 Ibatis有可能吗?
希望你明白我的问题。如果问题不明确,我很乐意重新编辑,以便让您清楚。
在此先感谢。