Hibernate Session.delete() an object if exists

前端 未结 7 1786
谎友^
谎友^ 2020-12-31 03:41

In JavaDoc of Session class the description of delete method is:

Remove a persistent instance from the datastore. The argument may be

7条回答
  •  爱一瞬间的悲伤
    2020-12-31 04:15

    You can easily achieve by following simple hibernate as follows,

    Session session=getSession();  
    String hql = "delete from Student where classId= :id"; 
    session.createQuery(hql).setString("id", new Integer(id)).executeUpdate();
    

提交回复
热议问题