Hi i am building a rest service to delete an entity from PostgreSQL using JPA. And the code is:
@Repository
public interface TestRepo extends JpaRepository<Question, Long>{
@Query(value = "delete from testmodel c where c.id in ?1 and c.name=?2",
nativeQuery = true)
void deleteModel(List<Long> ids, String text);
}
The code is working fine, the entries got deleted from PostgreSQL but i am getting the following exception in terminal.
org.postgresql.util.PSQLException: No results were returned by the query.
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:107) ~[postgresql-42.2.5.jar:42.2.5]
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) ~[HikariCP-3.2.0.jar:na]
When i searched for this exception i got a suggestion to use executeUpdate instead of executeQuery.
Since i am using JPA i don't know how to replace executeQuery with executeUpdate
Any help would be greatful.