当前使用版本(必填,否则不予处理)
v3.4.1
该问题是如何引起的?(确定最新版也有问题再提!!!)
union 或 union 分页查询
重现步骤(如果有就写完整)
CREATE VIEW v_homework_assignment as
select
id,1 as message_type,review_status, sender_id,receiver_id,title,image_url,video_url,cover_url,remarks,create_time,
0 as stage,0 as status,0 as frequency, 0 as bpm, 0 as staff, 0 as duration, 0 as type, '' as sheet_name_cn, '' as sheet_name_en, 0 as sheet_id
from sys_evaluation where review_status in (1,2)
UNION ALL
select
h.id,2 as message_type, h.review_status,h.teacher_id as sender_id, h.student_id as receiver_id, '' as title, '' as image_url, h.video as video_url, h.video_cover as cover_url, h.remark as remarks, h.c_time as create_time,
h.stage,h.status,h.frequency,h.bpm,h.staff, 0 as duration, 0 as type , s.name as sheet_name_cn, s.name_en as sheet_name_en, h.sheet_id
from homework h
LEFT JOIN sheet s on s.id = h.sheet_id
where h.review_status in (1,2)
UNION ALL
select
h.id, 3 as message_type, e.review_status, h.teacher_id as sender_id, h.student_id as receiver_id,'' as title, '' as image_url,e.path as video_url, e.cover as cover_url,'' as remarks, e.c_time as create_time,
h.stage, h.status,h.frequency,h.bpm,h.staff,e.duration,e.type, s.name as sheet_name_cn, s.name_en as sheet_name_en, e.sheet_id
from exercise e
INNER JOIN (select id,review_status,teacher_id,student_id, excersise_id,stage, status,frequency,bpm,staff from homework where (review_status in (1,2) ) and excersise_id is not null) h ON e.id = h.excersise_id
LEFT JOIN sheet s on s.id = e.sheet_id
创建视图 查询视图时用了union
报错信息
net.sf.jsqlparser.statement.select.SetOperationList cannot be cast to net.sf.jsqlparser.statement.select.PlainSelect
Comment From: miemieYaho
具体sql是什么样的?
Comment From: kyle18th
protected String autoCountSql(boolean optimizeCountSql, String sql) {
if (!optimizeCountSql) {
return lowLevelCountSql(sql);
}
try {
Select select = (Select) CCJSqlParserUtil.parse(sql);
PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
// ...
}
经过Debug, 存在union的sql执行select.getSelectBody()后得到的是SetOperationList而不是PlainSelect, 这里强转就报错了.