iBatis中怎样按条件选择不同的表来执行查询
1个回答
展开全部
在配置文件里面就可以修改
<select id="getXXXX" resultClass="xxxxxVO" parameterClass="xxxVO">
select * from
<isEqual property="xxxVO.falg" compareValue="A">
tableA
</isEqual>
<isEqual property="xxxVO.falg" compareValue="B">
tableB
</isEqual>
<isEqual property="xxxVO.falg" compareValue="C">
tableC
</isEqual>
</select>
或者
<select id="getXXXX" resultClass="xxxxxVO" parameterClass="xxxVO">
<isEqual property="xxxVO.falg" compareValue="A">
select * from tableA
</isEqual>
<isEqual property="xxxVO.falg" compareValue="B">
select * from tableB
</isEqual>
<isEqual property="xxxVO.falg" compareValue="C">
select * from tableC
</isEqual>
</select>
返回字段可以用别名统一就可以了
<select id="getXXXX" resultClass="xxxxxVO" parameterClass="xxxVO">
select * from
<isEqual property="xxxVO.falg" compareValue="A">
tableA
</isEqual>
<isEqual property="xxxVO.falg" compareValue="B">
tableB
</isEqual>
<isEqual property="xxxVO.falg" compareValue="C">
tableC
</isEqual>
</select>
或者
<select id="getXXXX" resultClass="xxxxxVO" parameterClass="xxxVO">
<isEqual property="xxxVO.falg" compareValue="A">
select * from tableA
</isEqual>
<isEqual property="xxxVO.falg" compareValue="B">
select * from tableB
</isEqual>
<isEqual property="xxxVO.falg" compareValue="C">
select * from tableC
</isEqual>
</select>
返回字段可以用别名统一就可以了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询