I'm struggling to write an HQL query to insert a new record into a table. I have seen some of the insert queries as shown below, but I do not want to insert data from another table as shown below.
String hql = "INSERT INTO Employee(firstName, lastName, salary)" +
"SELECT firstName, lastName, salary FROM old_employee";
Query query = session.createQuery(hql);
int result = query.executeUpdate();
System.out.println("Rows affected: " + result);
For example, I have a User table with three fields, such as name, age, number, and I have an entity for this user table. what will be the insert request for this?
source
share