Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Query(value="TRUNCATE TABLE ...", nativeQuery = true) fails with ClassCastException #3038

Closed
Hasoo opened this issue Jun 25, 2023 · 1 comment
Assignees
Labels
type: bug A general bug

Comments

@Hasoo
Copy link

Hasoo commented Jun 25, 2023

I'm upgrading spring boot 2.7.13 from 2.4.0.
When executing @query(value="TRUNCATE TABLE ...", nativeQuery=true), occurred below error.

Can you add a truncate table query like #2593 ?

Caused by: java.lang.ClassCastException: Cannot cast net.sf.jsqlparser.statement.truncate.Truncate to net.sf.jsqlparser.statement.select.Select at java.base/java.lang.Class.cast(Class.java:3605) ~[na:na]
at org.springframework.data.jpa.repository.query.JSqlParserQueryEnhancer.parseSelectStatement(JSqlParserQueryEnhancer.java:480) ~[spring-data-jpa-2.7.13.jar:2.7.13]
at org.springframework.data.jpa.repository.query.JSqlParserQueryEnhancer.parseSelectStatement(JSqlParserQueryEnhancer.java:493) ~[spring-data-jpa-2.7.13.jar:2.7.13]
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 25, 2023
@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 26, 2023
@mp911de mp911de self-assigned this Jun 26, 2023
@mp911de mp911de changed the title An error occurred when @Query(value="TRUNCATE TABLE ...", nativeQuery = true) @Query(value="TRUNCATE TABLE ...", nativeQuery = true) fails with ClassCastException Jun 26, 2023
@mp911de mp911de added this to the 2.7.14 (2021.2.14) milestone Jun 26, 2023
mp911de added a commit that referenced this issue Jun 26, 2023
…y type.

We now backoff from enhancing queries if the query type is not supported (e.g. TRUNCATE).

Closes #3038
mp911de added a commit that referenced this issue Jun 26, 2023
…y type.

We now backoff from enhancing queries if the query type is not supported (e.g. TRUNCATE).

Closes #3038
mp911de added a commit that referenced this issue Jun 26, 2023
…y type.

We now backoff from enhancing queries if the query type is not supported (e.g. TRUNCATE).

Closes #3038
@mp911de
Copy link
Member

mp911de commented Jun 26, 2023

That's fixed now and backported to 2.7.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants