public void testDml(){
Session session = null;
Transaction tx = null;
try {
session = HibernateUtils.getSession();
tx = session.getTransaction();
session.beginTransaction();
Query query = session.createQuery("delete Student s where s.id=?");
query.setInteger(0, 1);
query.executeUpdate();
tx.commit();
} catch (HibernateException e) {
tx.rollback();
e.printStackTrace();
}finally{
HibernateUtils.closeSession(session);
}
}
hibernate中用hql怎么执行delete的sql语句
最新推荐文章于 2021-04-15 01:57:40 发布