hibernate 中根据id删除一条记录的语句

qid name like content
1 A 1 the first text
2 B 2 the Second text
1 C 3 the Third text

 

 

如上表所示,当我们需要某个qid执行删除操作时,可以按照如下语句进行执行

 1         String hql="from bbsLikes  b where b.qid=(:ID)";
 2         String[] paramName={"ID"};
 3         Object[] value={qid}; 5         List list = this.getHibernateTemplate().findByNamedParam(hql, paramName, value);        
 6         if(!list.isEmpty()){
 7             this.getHibernateTemplate().deleteAll(list);
 8             return true;
 9         }
10         return false;    
11     }

 

版权声明:本文为lujun1949原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/lujun1949/p/6079146.html