Reputation: 155
when execute this query in hibernate getting error of "org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ON near line 1, column 132". can anyone help me on my code how to use ON for hibernate.
Session session = (Session) em1.getDelegate();
org.hibernate.Query q=session.createQuery("UPDATE sc_ob_temp_audit set export_flag ='Y' WHERE audit_id IN(select a.audit_id FROM sc_ob_temp_audit a JOIN sc_ob_allocation b ON a.sc_ob_profile_code = b.sc_ob_profile_code AND a.sc_orig_country= b.sc_orig_country LEFT OUTER JOIN sc_fac_group f ON b.sc_orig_country = f.sc_orig_country AND b.sc_orig_sf_group_code = f.sc_fac_group_code LEFT OUTER JOIN (SELECT e.gp_cnt_cd,d.sc_prod_cont_code,d.sc_prod_group_code,d.sc_orig_country, e.gp_cd FROM sc_ob_prod_group d LEFT OUTER JOIN gbl_product e ON d.sc_prod_cont_code = e. gp_cnt_cd)de ON b.sc_orig_country = de.sc_orig_country AND b.sc_prod_cont_group_code=de.sc_prod_group_code WHERE a.sc_orig_country=:countryCd AND a.export_flag= 'N')");
q.setParameter("countryCd", country.trim());
q.executeUpdate();
Upvotes: 0
Views: 1345
Reputation: 18170
You are trying to execute an SQL query - to do so you have to use the SQLQuery object instead. To get an SQLQuery
object just call session.createSqlQuery
On the other hand - why are you using Hibernate if you just end up writing SQL statements? Have you mapped the sc_ob_temp_audit
table?
Upvotes: 1
Reputation: 1429
After looking at your query it does not seems an hql. It looks like an sql query. use session.createSqlSquery instead session.createQuery.
Upvotes: 0