SQLUnionQueryTableSource没有实现父类SQLTableSourceImpl的clone方法,导致sqlserver在联合子查询中的分页解析出错。
类似如下SQL:
SELECT
t.*
FROM (
SELECT
logaudit.gmt_logged_ AS gmtLogged,
u.username_ AS userName,
logaudit.ip_ AS ip,
logaudit.action_ AS action,
logaudit.failed_ AS failed,
logaudit.module_ AS module,
logaudit.title_ AS title,
'' AS clientInfo
FROM
log_audit logaudit
LEFT JOIN sys_user u ON logaudit.user_id_ = u.id_
UNION
SELECT
login.gmt_logged_ AS gmtLogged,
login.user_username_ AS userName,
login.ip_ AS ip,
'登陆' AS action,
login.failed_ AS failed,
'' AS module,
'' AS title,
login.client_info_ AS clientInfo
FROM
log_login login
) AS t
ORDER BY
t.gmtLogged DESC
在分页的时候报错如下:
java.lang.UnsupportedOperationException: com.alibaba.druid.sql.ast.statement.SQLUnionQueryTableSource
at com.alibaba.druid.sql.ast.statement.SQLTableSourceImpl.clone(SQLTableSourceImpl.java:70)
at com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock.cloneTo(SQLSelectQueryBlock.java:447)
at com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock.clone(SQLSelectQueryBlock.java:410)
at com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock.clone(SQLSelectQueryBlock.java:39)
at com.alibaba.druid.sql.ast.statement.SQLSelect.clone(SQLSelect.java:203)
at com.alibaba.druid.sql.PagerUtils.limitSQLServer(PagerUtils.java:288)
at com.alibaba.druid.sql.PagerUtils.limit(PagerUtils.java:114)
at com.alibaba.druid.sql.PagerUtils.limit(PagerUtils.java:99)
at com.alibaba.druid.sql.PagerUtils.limit(PagerUtils.java:95)
at com.changhongedu.test.jdbc.SQLTest.main(SQLTest.java:90)
1条答案
按热度按时间vltsax251#
com.alibaba.druid.sql.ast.statement.SQLUnionQueryTableSource
里实现一下这个方法