hibernate常用.docVIP

  • 0
  • 0
  • 约2.59千字
  • 约 3页
  • 2018-02-24 发布于河南
  • 举报
hibernate常用

Hibernate批理更新与批量删除 批理修改: 场景:如有一个学生表Student,现有一属性[学院]改名,从计算机学院改为计算机工程学院[不考虑学院表]. 用Hibernate实现这种批理更新的方法一DML(数据操作语言)操作。代码如下: public void updateUser(String newName,String oldName) { Session session = null; try{ session = this.getSession(); Transaction tc = session.beginTransaction(); String hqlUpdate = update Student set deptName=:newName where deptName= :oldName; int updatedEntities = s.createQuery( hqlUpdate ) .setString( newName, newName ) .setString( oldName, oldName ) .executeUpdate(); mit(); }catch(RuntimeException re){ log.debug(re.get

文档评论(0)

1亿VIP精品文档

相关文档