2

When I do an executeUpdate on this SQL query in Hibernate 3.5:

Query insert = session.createSQLQuery(
"INSERT INTO unmapped_table_1 (column_name) "
    + "SELECT column_name "
    + "FROM source_table;");
insert.executeUpdate();

Hibernate returns the number of entries but does not insert the entries. When I do the query directly on the MySQL Server, the entries do get inserted.

4
  • 2
    Are you properly committing the transaction? Commented Nov 2, 2017 at 10:41
  • 2
    Set the hibernate.show_sql=true, what is the log output for query execution? Commented Nov 2, 2017 at 10:41
  • Have you tried select columns into unmapped_table_1 from source_table. ? Commented Nov 2, 2017 at 11:17
  • Call transaction commit after your code block. Commented Nov 2, 2017 at 11:23

1 Answer 1

1

May be your autocommit is not set to true, in this case you have to call commit() after query execution. By default Hibernate auto commit is false you can set autocommit to true withsetAutocommit(true)

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.