当前位置: 代码迷 >> Java Web开发 >> HQL语句的问题
  详细解决方案

HQL语句的问题

热度:211   发布时间:2008-07-01 08:48:03.0
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;
----------------解决方案--------------------------------------------------------
  相关解决方案