版本:0.2.26
一、MYBATIS里打印生成的SQL是这样的
Preparing: select count() from ( select * from ( select distinct RU_T. from ACT_RU_TASK RU_T inner join ACT_RE_PROCDEF RE_PD on RU_T.PROC_DEF_ID_ = RE_PD.ID_ left join ACT_RU_IDENTITYLINK RU_IL on RU_T.ID_=RU_IL.Task_Id_ where RU_T.Suspension_State_ = ? and RE_PD.KEY_ = ? and ( (RU_T.ASSIGNEE_=? ) or ( RU_IL.TYPE_ = ? AND RU_IL.USER_ID_ = ? ) or ( RU_IL.TYPE_ = ? AND RU_IL.Group_Id_ = ? ) ) )a where a.PROC_INST_ID_ in ( SELECT procinstiD FROM LEAVE ) )
二、相关参数
Parameters: 1(Integer), leave(String), u1(String), candidate(String), u1(String), candidate(String), bmjl(String)
三、DRUID打印出来的可执行SQL
SELECT COUNT()
FROM (SELECT *
FROM (SELECT DISTINCT RU_T.
FROM ACT_RU_TASK RU_T
INNER JOIN ACT_RE_PROCDEF RE_PD ON RU_T.PROC_DEF_ID_ = RE_PD.ID_
LEFT JOIN ACT_RU_IDENTITYLINK RU_IL ON RU_T.ID_ = RU_IL.Task_Id_
WHERE RU_T.Suspension_State_ = 1
AND RE_PD.KEY_ = 'leave'
AND (RU_T.ASSIGNEE_ = 'u1'
OR RU_IL.TYPE_ = 'candidate'
AND RU_IL.USER_ID_ = 'u1'
OR RU_IL.TYPE_ = 'candidate'
AND RU_IL.Group_Id_ = 'bmjl')
) a
WHERE a.PROC_INST_ID_ IN (SELECT procinstiD
FROM LEAVE)
)
四、问题
将and ( (RU_T.ASSIGNEE_=? ) or ( RU_IL.TYPE_ = ? AND RU_IL.USER_ID_ = ? ) or ( RU_IL.TYPE_ = ? AND RU_IL.Group_Id_ = ? ) )
解析成了
AND (RU_T.ASSIGNEE_ = 'u1'
OR RU_IL.TYPE_ = 'candidate'
AND RU_IL.USER_ID_ = 'u1'
OR RU_IL.TYPE_ = 'candidate'
AND RU_IL.Group_Id_ = 'bmjl')
丢失了括号,逻辑就不对了!
6条答案
按热度按时间mzsu5hc01#
你使用的druid的版本号提供一下的!
5anewei62#
版本:0.2.26
3xiyfsfu3#
其实两种的结果是一样的,没有区别的,
pu82cl6c4#
不会吧, jacking124,你好好看看,结果可不是一样的噢!!!!
vjhs03f75#
好吧,我在测试看看!
rks48beu6#
请问你是怎么打印出日志的?我在我的boot的配置文件中加了:
@bean
public Log4jFilter log4jFilter(){
Log4jFilter filter = new Log4jFilter();
filter.setStatementPrepareAfterLogEnabled(true);
filter.setStatementLogEnabled(true);
filter.setStatementExecuteAfterLogEnabled(true);
return filter;
}
还是打印不出来啊