最近遇到sql语句在pl/sql里能查出数据,但直接放到ibatis配置文件里却查询结果为空,语句为:
select p.* from t_petitionletter p join t_processflow f on p.processflow = f.id where f.flowstate = '办理'
发现[color=red]ibatis不支持直接在配置文件里写where子句,需要使用ibatis的动态where子句标签[/color]:
select p.* from t_petitionletter p join t_processflow f on p.processflow = f.id where f.flowstate = '办理'
发现[color=red]ibatis不支持直接在配置文件里写where子句,需要使用ibatis的动态where子句标签[/color]:
<select id="selectPetitionLetterForFlow" resultMap="PetitionLetterResult" parameterClass="string">
select p.* from t_petitionletter p join t_processflow f on p.processflow = f.id
<dynamic prepend="where">
<isNotEmpty prepend="and">
f.flowstate = #flowstate#
</isNotEmpty>
</dynamic>
</select>
本文介绍了一个常见问题的解决方案:当SQL语句在PL/SQL中能正确执行但在IBATIS配置文件中查询结果为空时,如何通过使用IBATIS的动态WHERE子句来修正此问题。
373

被折叠的 条评论
为什么被折叠?



