Skip to content

JSqlParserQueryEnhancer fails with ClassCastException during query introspection #3869

Closed
@thmasker

Description

@thmasker

I have a repository which includes a method to call a PostgreSQL function:

public interface ARepository extends JpaRepository<A, Long> {

  @Query(value = "SELECT is_contained_in(:innerId, :outerId)", nativeQuery = true)
  boolean isContainedIn(@Param("innerId") long innerId, @Param("outerId") long outerId);

}

This compiles and works without problem. However, tests fail due to:

Caused by: java.lang.ClassCastException: class net.sf.jsqlparser.statement.select.Select cannot be cast to class net.sf.jsqlparser.statement.select.PlainSelect (net.sf.jsqlparser.statement.select.Select and net.sf.jsqlparser.statement.select.PlainSelect are in unnamed module of loader 'app')

I found out that the casting failure is produced in class JSqlParserQueryEnhancer, line 240:

for (SelectItem<?> selectItem : ((PlainSelect) selectBody).getSelectItems()) {

And I think it could be fixed by updating it to:

for (SelectItem<?> selectItem : selectBody.getPlainSelect().getSelectItems()) {

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions