有一个非常强大的功能,称为:
[15.4。DML风格的 *** 作](http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch15.html#batch-direct)
来自doc的小引用:
因此,尽管这不是关于 criteria
-我们仍然可以使用我们的域模型进行查询,因为它与 HQL 有关。这是显示功能的代码段:
Session session = sessionFactory.openSession();Transaction tx = session.beginTransaction();String hqlUpdate = "update Customer c set c.name = :newName where c.name = :oldName";// or String hqlUpdate = "update Customer set name = :newName where name = :oldName";int updatedEntities = s.createQuery( hqlUpdate ) .setString( "newName", newName ) .setString( "oldName", oldName ) .executeUpdate();tx.commit();session.close();
简介:具有以下特点:
- 我们可以使用查询来过滤结果
- 我们可以对其进行批量更新
- 我们不需要将内存中的这些行加载到会话中…
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)