Beginner |
 |
Joined: Mon Oct 30, 2006 12:46 am Posts: 26
|
Hi ,
Till now i have used HQL for creating and retrieving the data from database. It worked successfully. But i yday i tried for updating the record by using below sample code.
-------------------------------------------------------------------------
public int updateCommand(long commandId,Component component)
{
log.debug("Inside:updateCommand");
try
{
Session session = HibernateSessionFactory.getSession();
Transaction tx = session.beginTransaction();
String hqlUpdate="update Command comm set comm.component="+component+" where comm.commandId ="+commandId;
Query updateQuery=session.createQuery(hqlUpdate);
int update=updateQuery.executeUpdate();
tx.commit();
session.close();
log.debug("Successfully updated");
return update;
}catch (RuntimeException re) {
log.error("Updation failed ");
throw re;
}
}
--------------------------------------------------------------------------------
Here i am getitng error saying that executeUpdate not there at Query.
Could anyone help me how to update/delete records thru HQL effectivily.
Eagerly waiting for youe replys.
Thanks
Praveen.
|
|