i new hibernate trying insert data table using hql. below code. when in run code getting below exception. tried googling wrote code in same way. guess missing in code
configuration conf = new configuration(); conf.configure("hibernate.cfg.xml"); sessionfactory factory = conf.buildsessionfactory(); session session = factory.opensession(); transaction txn = session.begintransaction(); query qry = session.createquery("insert item (username, age, id)"+" select e.username, e.age, e.id employee e "); //qry.setparameter(0, 1); int res = qry.executeupdate(); txn.commit();
exception:
exception in thread "main" org.hibernate.hql.ast.querysyntaxerror: unexpected token: insert near line 1, column 1 [insert item (username, age, id) caused by: line 1:1: unexpected token: insert
Comments
Post a Comment