Closed
Description
When starting a Spring Boot application with >= 2.7.0 the application fails to start if it has native INSERT queries defined in JpaRepositories. The error is:
java.lang.ClassCastException: class net.sf.jsqlparser.statement.insert.Insert cannot be cast to class net.sf.jsqlparser.statement.select.Select
For example, any JpaRepository with the following will error and prevent the application from starting:
@Modifying
@Query(value = "INSERT INTO FOO(A) VALUES('A')", nativeQuery = true)
void insertFoo();
detectParsedType()
appears to neglect the Insert statement type:
Statement statement = CCJSqlParserUtil.parse(this.query.getQueryString());
if (statement instanceof Update) {
return ParsedType.UPDATE;
} else if (statement instanceof Delete) {
return ParsedType.DELETE;
} else if (statement instanceof Select) {
return ParsedType.SELECT;
} else {
return ParsedType.SELECT;
}