记得说不能执行,把提示信息copy进来,改成下面的试试
String hql="delete  qxEntity where qxid=?"; 
qxEntity是类名? 是的话第一个字母怎么是小写的

解决方案 »

  1.   

    貌似delete和update操作时as不用!
      

  2.   

    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    Hibernate: delete from Sort_table where Sid=10
    org.hibernate.exception.ConstraintViolationException: could not execute update query
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.hql.ast.exec.BasicExecutor.execute(BasicExecutor.java:84)
    at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:334)
    at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:209)
    at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1126)
    at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:94)
    那个是类名,QxEntity应该是这样的,上面传错了.......
      

  3.   

    String hql="delete qxEntity qx where qx.qxid=?"; 
      

  4.   

    抛出的错误是这样的query must begin with SELECT or FROM: delete 吗?
    如果是 的话,在hibernate的配置文件看看有没有
    <property name="hibernate.query.factory_class">
    org.hibernate.hql.classic.ClassicQueryTranslatorFactory
    </property>
    有的话去掉就可以了
      

  5.   

    还是不好使的,怎么现在Hibernate显示出删除语句了,可是数据库中没有丝毫改变的.....
    请求帮忙!!!
      

  6.   

    getHibernateTemplate().delete(id); 一句代码搞定
      

  7.   

    getSession().beginTransaction()实务放到Query query=getSession().createQuery(hql); 
    前  然后载提交实务看一下
      

  8.   

    执行完update和delete的操作后记住要session.flush()
      

  9.   

    级联关系我已经做好了的,现在报的异常是could not execute update query的
      

  10.   

    用一下session.delete()试一下。比如这样:public static boolean DeleteContext(Context context,int id){
    try{
    Session session=HibernateSessionFactory.getSession();
    session.beginTransaction();
    context.setId(id);
    session.delete(context);
    session.getTransaction().commit();
    session.close();
    return true;
    }catch(Exception e){
    return false;
    }
    }
      

  11.   

    看看你的Context 类是怎么写的,是否把一对多关联的cascade设置成了all
      

  12.   


    delete 语句可以的,我用过。
      

  13.   

    delete from Bean where id=?