注册 登录
编程论坛 J2EE论坛

HQL语句的问题

Jiaoliu888 发布于 2008-07-01 08:48, 1391 次点击
帮忙看一下这个语句有问题吗?
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();
        
    }
2 回复
#2
netstriker2008-07-02 00:10
// String hql = "delete UsersDto where id="+id;
   印像中是 "delete from UserdDto where ........."

  还有的是是事务提交前应该是
  Transaction tr =  super.getSession().beginTransaction();
  tr.begin();      //开始
    q.executeUpdate();  //事务执行
   ();   //提交,自动flush session了
#3
高寒2008-07-11 17:31
String hql = "delete from UsersDto where id="+id;
1