ibatis 2中,能配置文件中动态指定字段么?在ibatis 2中,比如有ownerid ownertype两个字段,当ownertype=1时,onwerid
要到A表的a字段进行关联,当onwertype=0时,ownerid要到B表的B字段进行关联,这个在sqlmapper的xml文件中,能配置到么?
:twisted:
[code="java"]
ownerid in (select $currentField$ from $currentTable$)
[/code]
查询时,传入
map.put("currentField", "a");
map.put("currentTable", "A");
map.put("compareField","ownertype");
亲,看看这个是不是你想要的!
[code="xml"]
ownerid in (select a from A)
[/code]
亲,我有说ownertype一定就是POJO的属性吗?
这里它就相当于一个参数,你只要在传值的时候传入这个参数就OK!
我们通常对一个字段多做判断的情况不就是那样做的吗?
[code="xml"]
ID = #id#
ID in ($ids$)
[/code]
这里的ids就是一个参数而已,你试一下咯~