No results returned by the Query error in PostgreSQL
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)