Hibernate中两种删除用户的方式

mac2022-07-05  14

第一种,是比较传统的,先根据主键列进行查询到用户,在进行删除用户

//删除数据 public void deleteStudent(String sno) { init() ; Student qu =(Student) se.get(Student.class, sno) ; se.delete(qu); destroy(); }

第二种,直接运用HQL语句进行删除

//删除数据 public void deleteStudent(String sno) { init() ; se.createQuery("delete from Student where sno = ?") .setString(0, sno).executeUpdate() ; destroy(); }

 

转载于:https://www.cnblogs.com/20gg-com/p/6125851.html

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)