Hibernate3 批量更新/删除
Hibernate3 对批量更新和批量删除提供了支持,能够直接执行批量更新或批量删除语句,无需把被更新或删除的对象先加载到内存中。
以下是通过Hibernate3 执行批量更新的程序代码:
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
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();
以下是通过Hibernate3.0执行批量删除的程序代码:
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
String hqlDelete = "delete Customer where name = :oldName";
int deletedEntities = s.createQuery( hqlDelete )
.setString( "oldName", oldName )
.executeUpdate();
tx.commit();
session.close();
- (10-02-25 00-00)hibernate的批量删除
- (10-02-25 00-00)关于用信号量Semaphore实现互斥锁Mutex
- (10-02-25 00-00)Javascript 操作select控件大全(新增、修改、删除、选中、清空、判断存在等)
- (10-02-25 00-00)信号量
- (10-02-25 00-00)远程执行本地命令
- (10-02-25 00-00)Onunload与Onbeforeunload
- (10-02-25 00-00)改变mysql数据包1M的限制
- (10-02-25 00-00)jQuery-位置选择器
- (10-02-25 00-00)jQuery-位置选择器
- (10-02-25 00-00)jQuery-创建元素包装集