mybatics中【】mybatis的if判断

1、问题:

正常在mapper.xml中使用test,最常用的就是判断某个属性不为空,则对其进行赋值,如下:

and fav.accNo = #{accNo}

但是有时候可能需要在mapper.xml中根据传参条件进行查不同表进行判断,如下:


AND NOT EXISTS (
select 1 from fj_check_bill cb,fj_check c
where
cb.paymentId = fav.paymentId
and  cb.premiumFlag='1' 
and  cb.premiumVATFlag='1'
and c.validFlag='0'
and cb.checkBillNo = c.checkBillNo
)



AND NOT EXISTS (
select 1 from fj_settle_bill fsb,fj_settle s
where
fsb.paymentId = fav.paymentId
and  fsb.premiumFlag='1' 
and  fsb.premiumVATFlag='1'
and s.validFlag='0'
and fsb.settleNo = s.settleNo
)

但是,这种传递方式springMVC中解析为字符,不是强对象类型,因此需要做对应的转义操作,如下:

(1)
AND NOT EXISTS (
select 1 from fj_check_bill cb,fj_check c
where
 cb.paymentId = fav.paymentId
 and  cb.premiumFlag='1' 
 and  cb.premiumVATFlag='1'
 and c.validFlag='0'
 and cb.checkBillNo = c.checkBillNo
)

(2)accountAdjustType == "1" ' >
AND NOT EXISTS (
select 1 from fj_check_bill cb,fj_check c
where
 cb.paymentId = fav.paymentId
 and  cb.premiumFlag='1' 
 and  cb.premiumVATFlag='1'
 and c.validFlag='0'
 and cb.checkBillNo = c.checkBillNo
)

或者改为

你可能感兴趣的:(mybatics中【】mybatis的if判断)