I'm trying to use hibernate to make a simple SQL UPDATE query and map the result row into Hibernate entity (Using the createSQLQuery).
String updateQuery =
String.format("UPDATE \"user\" "
+ "SET chips_balance=chips_balance + %d, diamonds_balance=diamonds_balance + %d "
+ "WHERE id=%d", chips_delta, diamonds_delta, userId);
User user = (User)session.createSQLQuery(updateQuery).uniqueResult();
This throws an Exception:
org.hibernate.exception.GenericJDBCException: could not extract ResultSet
Cause:
org.postgresql.util.PSQLException: No results were returned by the query.
How can I make this work? (Using the RETURNING keyword)