hibernate 的delete 是根据主键删除,可是你直接传个有主键的对象 直接delete,hibernate 会自动回滚,如果想delete 可以先根据id get查出来,在delete .
也可以写hql语句,session.createQuery("delete 对象名 where id=?).setParameter(0,id).executeUpdate() ;
hibernate 的delete 是根据主键删除,可是你直接传个有主键的对象 直接delete,hibernate 会自动回滚,如果想delete 可以先根据id get查出来,在delete .
也可以写hql语句,session.createQuery("delete 对象名 where id=?).setParameter(0,id).executeUpdate() ;