sql - HQL query not working, Incorrect syntax near ',' error. Using Spring and Hibernate -
i trying execute following update query , getting error,
query is=
@transactional public list<order> getclosedorders(string userid) throws dataaccessexception { try { string sql_select_query = "from order o o.orderstatus='closed' , o.account.profile.userid='"+userid+"'"; string sql_update_query = "update order set orderstatus=completed orderstatus=closed , account.profile.userid='"+userid+"'"; list<order> orderlist = (list<order>) list(sql_select_query); if(!orderlist.isempty()) { batchupdate(sql_update_query); return orderlist; } return null; } catch(exception ex) { ex.printstacktrace(); throw new dataaccessexception(errormessage); } }
however select query working update query giving following error:
warn [http-8080-2] (jdbcexceptionreporter.java:71) - sql error: 102, sqlstate: s0001
error [http-8080-2] (jdbcexceptionreporter.java:72) - incorrect syntax near ','.
org.hibernate.exception.sqlgrammarexception: not execute update query
at org.hibernate.exception.sqlstateconverter.convert(sqlstateconverter.java:67)
at org.hibernate.exception.jdbcexceptionhelper.convert(jdbcexceptionhelper.java:43)
at org.hibernate.hql.ast.exec.basicexecutor.execute(basicexecutor.java:84)
at org.hibernate.hql.ast.querytranslatorimpl.executeupdate(querytranslatorimpl.java:334)
at org.hibernate.engine.query.hqlqueryplan.performexecuteupdate(hqlqueryplan.java:209)
i don't understand why happening. not using "," anywhere in query still says incorrect syntax near',' why so? how solve this? thank in advance.
first of all:
<property name="hibernate.show.sql" value="true"></property>
it lot.
second of all:
string sql_update_query = "update order set orderstatus=completed orderstatus=closed , account.profile.userid=:userid";
and use
addstring("userid",userid);
may these changes eliminate problem.
Comments
Post a Comment