Hibernate HQL delete with and

前端 未结 4 2076
名媛妹妹
名媛妹妹 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:10

            int deletedRows = 0;
            try {
                session = sessionProvider.get();
                String hql = "delete from ApprovalRemark approvalRemark where approvalRemark.approvalItem.id =:approvalItemId ";
                Query query = session.createQuery(hql);
                query.setParameter("approvalItemId", approvalItemId);
                deletedRows = query.executeUpdate();
            } catch (javax.persistence.NoResultException e) {
                return false;
            } catch (HibernateException he) {
                log.error("deleteAllApprovalRemarksForApprovalItem exception", he);
                throw he;
            }
            log.debug("deleteAllApprovalRemarksForApprovalItem deleted " + deletedRows + " rows");
            return true;
    

提交回复
热议问题