对于下面这样的包含子查询的语句,在ibatis中怎么处理?只能拼SQL了?
select * from agent where province_code in(select province_code from operator_biz_province where operator_id =%d)
[b]问题补充:[/b]
province_code in(select province_code from operator_biz_province where operator_id =%d) 是变化的,比如
operator_id in(....)
[b]问题补充:[/b]
我现在是做成:
select * from agent $conditions$
conditions的值是自己拼SQL语句,再通过map传到ibatis中。
想知道有没有更好的方法
这样的, 你可以传operator_id的list进来,
iBATIS是有一个iterator的, 可以循环list.
我的代码的参数是传入A对象,
[code="java"]class A {
List status;
}
<isNotNull property="status">
<isNotEmpty prepend="AND " property="status">
<iterate property="status" open=" STATUS IN (" close=")" conjunction=", ">
#status[]#
</iterate>
</isNotEmpty>
</isNotNull>
[/code]
可以直接写在SqlMap中呀?
有问题么? :o