Inserting data in one table using HQL in Hibernate

You don’t need to use hql to insert if the data is from another table.

Simply get a reference to your entity, get a hold of a Hibernate session, and call save().

According to http://docs.jboss.org/hibernate/orm/4.0/devguide/en-US/html/ch04.html#d0e2116

Pseudo-syntax for INSERT statements

INSERT INTO EntityName properties_list select_statement

Only the INSERT INTO … SELECT … form is supported. You cannot specify explicit values to insert.

Leave a Comment