Emmanuel Guiton
Emmanuel Guiton

Reputation: 1445

JPA / JPQL query without resultSet nor update/delete count

I wish to execute a (Postgre)SQL native query that is not a "SELECT" nor an "UPDATE" nor a "DELETE" query. It is "REFRESH MATERIALIZED VIEW view_name;" and has no result as far as I know.

What is the right way to execute such a query using JPA / JPQL ?

Execution methods on javax.persistence.Query seem to require a result set or an update/delete count.

Upvotes: 1

Views: 234

Answers (1)

Emmanuel Guiton
Emmanuel Guiton

Reputation: 1445

In the end, executeUpdate() was the correct way to do the job.

final javax.persistence.EntityManager em;
em.createNativeQuery("REFRESH MATERIALIZED VIEW view_name;").executeUpdate();

Upvotes: 1

Related Questions