public void batchDelete(final Integer[] arrayID) {
this.getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException, SQLException {
String hql = "delete from Userdb as model where model.id = :id";
Query query = session.createQuery(hql);
for(int i=0; i<arrayID.length; i++) {
query.setString("id", String.valueOf(arrayID[i]));
query.executeUpdate();
}
return null;
}
});
}ssh结构
批量删除,这样写可以吗
已经写了aop事务管理,还需要写Transaction ta = session.beginTransaction();这句吗