操作:删除某新闻类型下的所有新闻方法一:
super.getHibernateTemplate().deleteAll(
super.getSession().createCriteria(News.class).add(
Expression.eq("newstype.id", id)).list());方法二:
super.getSession()
.createQuery("delete News n where n.newstype.id=:id")
.setInteger("id", id).executeUpdate();
两种方法 哪种方法效率要高点?为什么?
super.getHibernateTemplate().deleteAll(
super.getSession().createCriteria(News.class).add(
Expression.eq("newstype.id", id)).list());方法二:
super.getSession()
.createQuery("delete News n where n.newstype.id=:id")
.setInteger("id", id).executeUpdate();
两种方法 哪种方法效率要高点?为什么?
解决方案 »
- 怎么样用正则表达式验证 不能有重复数字 并且只能从1-9升序 把下面代码修改下
- 请教一个servlet存放的问题
- spring的TransactionTemplate的疑惑
- 关天struts源码的一个简单问题?
- jsf如何封装数组与list
- 使用hibernate插入大对象异常
- struts 关于从数据库读出数据,页面汉字乱码
- 遭遇com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
- spring 事务 propagation REQUIRES_NEW 未起到新建事务的作用
- 请教关于华为cmpp API的短信接收方式的使用情况,急!!
- SSH与EJB3.0
- .properties 编码问题
第一种是先list,然后删除
第二个是直接删除
第二种方法直接执行sql--
偶觉得也是第二种
<key column="member_id"> </key>
<one-to-many class="hbp.ch04.ex03.model.Order"/>
</set>
(2)子表:<many-to-one name="member" column="member_id" class="hbp.ch04.ex03.model.Member" cascade="delete"> </many-to-one>
试试