/**
* 根据id删除普通用户
*/
public void deleteById(int id) {
System.out.println("deleteById");
//获得session
Session session = hibernateTemplate.getSessionFactory().openSession();
String str = "delete from ptuser where id="+id;
System.out.println(str);
//开启事务
session.beginTransaction();
//用原始的SQL操作,通过createSQLQuery写入SQL语句,通过executeUpdate执行操作
session.createSQLQuery(str).executeUpdate();
//提交事务
session.getTransaction().commit();
}
时间: 2024-12-15 01:54:50