67,512
社区成员
发帖
与我相关
我的任务
分享
String hql=" update News news set news.del=0 where news.id in ("+idlist+")";
HibernateTemplate ht =this.getHibernateTemplate();
List<News> list=ht.find(hql);
int result=0;
Session session=this.getHibernateTemplate().getSessionFactory().openSession();
try{
result= session.createSQLQuery("update News set del=0 where id in("+idlist+")").executeUpdate();
}finally {
this.releaseSession(session);
}
return result>0;
还是异常了,createSQLQuery这个方法的参数是sql 还是hql呀
Session session=this.getHibernateTemplate().getSessionFactory().openSession();
try{
session.createSQLQuery("sql语句").executeUpdate();
}finally {
this.releaseSession(session);
}
String hql=" update News news set news.del=0 where news.id in ("+idlist+")";
HibernateTemplate ht =this.getHibernateTemplate();
int ret=ht.executeUpdate(hql); //int返回是成功修改了多少条数据的数量
试试看吧