-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Hello Team.
Upgrading to Spring Data 2.7.x and having com.github.jsqlparser in the classpath prevents the application to start if repositories use native queries.
Caused by: java.lang.ClassCastException: class net.sf.jsqlparser.statement.select.SetOperationList cannot be cast to class net.sf.jsqlparser.statement.select.PlainSelect (net.sf.jsqlparser.statement.select.SetOperationList and net.sf.jsqlparser.statement.select.PlainSelect
A query similar to
select SOME_COLUMN from SOME_TABLE where REPORTING_DATE = :REPORTING_DATE
except
select SOME_COLUMN from SOME_OTHER_TABLE where REPORTING_DATE = :REPORTING_DATEfails to parse because jsqlparser returns a SetOperationList object instead of PlainSelect
This is directly typecasted in class JSqlParserQueryEnhancer
private String detectAlias(String query) {
if (this.parsedType != ParsedType.SELECT) {
return null;
}
Select selectStatement = parseSelectStatement(query);
PlainSelect selectBody = (PlainSelect) selectStatement.getSelectBody();
return detectAlias(selectBody);
}
It would be useful if we can give a flag to choose which QueryEnhancer user wants to use. There will be multiple cases where jsqlparser is on the classpath for historical project but either they won't be able to upgrade because of breaking changes in jsqlparser or they do not intend to use is as QueryEnhancer.