How to write insertinto command in sleeping criteria

I want to write an InsertInto query in Hibernate Criteria below. Any suggestions .. thanks for the help

sql = "insert into selectedresumes values('" + companyId + "','" + resumeId + "','" + resumeStatusId + "','" + jobId + "')"; 
+4
source share
2 answers

Unfortunately, you cannot do this.

According to Hibernate documentation

http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#batch-direct

Only INSERT INTO ... SELECT ... form is supported; not INSERT INTO ... VALUES ... form.

So, you just need to create an Object and save it using Hibernate, and it should look something like this.

 Session session = sessionFactory.openSession(); Transaction tx = session.beginTransaction(); Resume selectedresumes = new Resume(); //set all resume values session.save(selectedresumes); tx.commit(); session.close(); 
+1
source

You should map your queries to the pojo class, not to SQL or MySQL databases.

As below For Employee, the pojo object has two empNo, empName fields to insert a record, as shown below. Request Request = session.createQuery ("insert into Employee (empNo, empName)");

int result = query.executeUpdate ();

see this example

http://howtodoinjava.com/hibernate/hibernate-insert-query-tutorial/

0
source

All Articles