问题描述
- hibernate 执行此条delete Lc_Admin where id in(?)删除第一个
-
?public boolean runByHql(String hql, Object...params) {
try {
Query query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery(hql);
if(params != null && params.length>0){
for(int i=0;i<params.length;i++){
query.setString(i, params[i].toString());
}
}
query.executeUpdate();
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}?String hql = "delete Lc_Admin where id in(?)";
为什么执行此条hql语句时,能执行成功。但是删除多个id时[1,2,3],只能执行成功一个id的数据[1]!!!
解决方案
在数据库中执行删除delete语句时出现:You are using safe update mode and you tried to update a table without a WHERE
org.hibernate.AssertionFailure: null id in net.test.entity.test entry (don't flush the Session
How does ASM work with RAID where striping and mirroring are already built-in [ID 330398.1]
----------------------
解决方案二:
in的时候需要传入list、或者数组吧。setParameterList
时间: 2024-09-20 08:53:13