update query using SQLQuery in Hibernate -
i have this: suppose:
int posterid=100; int userid=5; sqlquery query=session.createsqlquery("update poster set userid='"+userid+"' posterid='"+posterid+"' "); query.executeupdate();
it not working, if write:
sqlquery query=session.createsqlquery("update poster set userid=:userid posterid=:posterid "); query.setparameter("userid",userid); query.setparameter("posterid",posterid); query.executeupdate();
is not working too.
session.begintransaction();
sqlquery query=session.createsqlquery("update poster set userid='"+userid+"' posterid='"+posterid+"' ");
query.executeupdate();
session.gettransaction().commit();
Comments
Post a Comment