No results returned by the Query error in PostgreSQL

I am trying to insert a data into a table. After executing the query i am getting an exception stating

org.postgresql.util.PSQLException: No results were returned by the query.
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:284)

The data is getting inserted successfully, but i have no idea why i am getting this exception ??


Use

executeUpdate

instead of

executeQuery

if no data will be returned (i.e. a non-SELECT operation).


Please use @Modifying annotion over the @Query annotion.

@Modifying
@Query(value = "UPDATE Users set coins_balance = coins_balance + :coinsToAddOrRemove where user_id = :user_id", nativeQuery = true)
    int updateCoinsBalance(@Param("user_id") Long userId, @Param("coinsToAddOrRemove") Integer coinsToAddOrRemove); 

The same is true for any DML query (i.e. DELETE, UPDATE or INSERT)