0

Hibernate executeUpdate() for insert or update native query with returning * gives and exception and also does not update the tables.

SQLQuery query = session.createSQLQuery(
      "INSERT INTO public.account (username) VALUES ('xx'), ('yy'), ('zz') RETURNING user_id");

Transaction tx = session.beginTransaction();
query.executeUpdate();
tx.commit();

Exception:

org.postgresql.util.PSQLException: A result was returned when none was expected.

1 Answer 1

2

executeUpdate() is only appropriate if the SQL statement does not return result rows.

Use iterate(), list() or scroll() instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.