HQL语句的问题
帮忙看一下这个语句有问题吗?public void delete(int id) throws Exception {
String hql = "delete UsersDto where id="+id;
Query q = super.getSession().createQuery(hql);
q.executeUpdate();
super.getSession().beginTransaction().commit();
}
搜索更多相关主题的帖子:
HQL 语句
----------------解决方案--------------------------------------------------------
// String hql = "delete UsersDto where id="+id;
印像中是 "delete from UserdDto where ........."
还有的是是事务提交前应该是
Transaction tr = super.getSession().beginTransaction();
tr.begin(); //开始
q.executeUpdate(); //事务执行
tr.commit(); //提交,自动flush session了
----------------解决方案--------------------------------------------------------
String hql = "delete from UsersDto where id="+id;
----------------解决方案--------------------------------------------------------