增加我是不知道有什么办法,可是你的批量删除不应当这样吧
删除应当是session.delete("from T_first a where a.id=1");
System.out.println(a);
session.flush();
session.close();
这样删除应当没有问题

解决方案 »

  1.   

    T_first ss=(T_first)session.load(T_first.class,new Integer(2));
    ss.setName("geezer");
    ss.setSex("ni");
    session.update(ss);//更新需要加上这条语句才行
    session.flush();
    session.close();
      

  2.   

    ymm(紫外线)
    我就是按照你写的那样不行,显示的sql如下:
    Hibernate: select t_first0_.id as id, t_first0_.name as name, t_first0_.sex as sex from t_first t_first0_ where (t_first0_.id=1 )
    1
    Hibernate: delete from t_first where id=?
    但是还是不能在数据库中删除数据。 joincsdn(云)
    我按照你说的也不行,加上session.update(ss);或者session.saveOrUpdate(ss)(我以前加的)都不行
    显示的sql是
    Hibernate: select t_first0_.id as id0_, t_first0_.name as name0_, t_first0_.sex as sex0_ from t_first t_first0_ where t_first0_.id=?
    Hibernate: update t_first set name=?, sex=? where id=?
    应该是找不到传进去的值,这是为什么?
      

  3.   

    pbMaster(编程无境界) 
    应该不用,因为hibernate直接就把修改的session保存了。
      

  4.   

    更新你不用saveorupdate啊?
    int a = session.delete("from T_first ");是这样用啊???晕
    你看看文档把,上面又介绍的
      

  5.   

    hibernate进行数据修改和删除时是需要session.beginTransaction();然后再tran.commit();的,否则hibernate不会把更新的数据提交到数据库
      

  6.   

    yohar(砍野菜的武當劍)
    tran是什么,在什么地方加?