Skip to content
Advertisement

The native sql query to Postgresql via the @query annotation is not executed

To get the necessary data, I form an SQL query to PostgreSQL, which is a related set of View tables :

When I execute these queries from the console in the database sequentially, one after the other, everything works.

However, if you run similar queries in the repository via the @query annotation (“… ” , NativeQuery = true), a number of errors occur and the queries break down in the end without returning anything. How is this possible and what should I do?

My service it looks like this:

Repository:

Service:

When trying to execute .It returns “the query did not return results” , the Hibernate SQL debugger says that only query number 1 worked. “Hibernate: create or replace view camera_layout AS select layout_id, unnest(layout.camera_ids) as camera_id from layout” the rest break down, although they should work help me, I am very grateful in advance

Advertisement

Answer

As stated here DDL statements need to be annotated with @Modifying annotation, so your repository methods should look like this:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement