hibernateTemplate删除一个对象
不能这样删除
public void deleteNewsCategoryByNewsCategoryId(int newsCategoryId) {
hibernateTemplate.delete(hibernateTemplate.find("from NewsCategory nc where nc.id=?", newsCategoryId));
}
正确删除方法:
//删除分类
public void deleteNewsCategoryByNewsCategoryId(int newsCategoryId) {
hibernateTemplate.delete(hibernateTemplate.get(NewsCategory.class, newsCategoryId));
}