spring-projects / spring-data-jpa

Simplifies the development of creating a JPA-based data access layer.

Home Page:https://spring.io/projects/spring-data-jpa/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IDE reports unexpected query tokens on `@Query(INSERT …`

3066097899 opened this issue · comments

1 2 **Why does the "Insert unexpected" issue occur during the insert operation when I configure the custom operation database method in JPA? SQL statements, regardless of capitalization, cannot solve it**

If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal yet complete sample that reproduces the problem.
You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

study_jpa_query.zip
In this project, I am learning to use a custom sql method in the JPA operating database. When I define an "INSERT" method, the "INSERT unexpected" problem occurs. I use the "@ Query annotation" where the problem occurs. After I use mybaties, I call the @ Insert annotation in mybaties to solve the problem. How can I solve the problem without using mybaties

In this project, I am learning to use a custom sql method in the JPA operating database. When I define an "INSERT" method, the "INSERT unexpected" problem occurs. I use the "@ Query annotation" where the problem occurs. After I use mybaties, I call the @ Insert annotation in mybaties to solve the problem. How can I solve the problem without using mybaties

The code is a pretty wild mix of annotations. Generally speaking, Spring Data isn't raising any IDE errors, that's the responsibility of IDE plugin authors. For any modifying queries, please add @Modifying to indicate that the query is running insert/update/delete statements. Also, the @Query("INSERT INTO …) query is missing nativeQuery = true.