Hibernate HQL delete with and

前端 未结 4 2061
名媛妹妹
名媛妹妹 2021-02-12 22:45

Hibernate doesn\'t delete my row:

public boolean deleteVote(Login user, int pid){

      Session session = getSession();

      try{
          String hql = \"del         


        
4条回答
  •  长发绾君心
    2021-02-12 23:20

    From the Output you provided

    uid: 123 and pid: 1
    Hibernate: delete from votes where uid=? and pid=?
    1
    

    it is clear that query.executeUpdate() is returning 1. The method returns the number of entities updated or deleted. This means that 1 row has been updated or deleted, which is okay.

    Try doing a session.flush() to flush the session, or a session.evict() to remove the object from the session.

提交回复
热议问题